Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Submission Format: 1. The project should be submitted using the Blackboard. 2. I

ID: 3704237 • Letter: S

Question

Submission Format: 1. The project should be submitted using the Blackboard. 2. Include all files in one folder and compress your folder using (.zip) not rar 3. Includes all the following files in one folder A. The code and the files necessary to compile and test the project. B. Test Plan: Showing how you tested the program (show the steps of your testing procedure along with screen shots). (10 points) C. A short description of the design plan and general comments. (5 points) Write a C++ program to manage a library system. The main user is the librarian. Build Specifications (35 points) I. The system should load a catalog of books, journals, and magazines at the start of the program. (at least five of each) 2. A user can search the catalog: The user of the system can search the library's catalog magazine). If you are looking specifically for a book, you can search by the name of the author. by using the name of the item. Also, a user can list books by category (Book, Journal, or 3. A user can check out books, journals, or magazines: The user needs to find the item first, then they can check it out. A user cannot check out an item that is already checked out. 4. A user can return books. journals, or magazines: A user can returm an item. The user needs to find the item first, then they can return it. 5. Add new books, journals, or magazines to the catalog. A librarian can add a new item to the catalog

Explanation / Answer

/* Hi below java program alloes you to add and sesrch items


public class example{


public void additem(String category , String catalog, String book ){
    //JDBC driver name and database URL
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://localhost/STUDENTS";
     // Database credentials
    static final String USER = "username";
     static final String PASS = "password";
      public static void main(String[] args) {
        Connection conn = null;
         Statement stmt = null;
         //STEP 2: Register JDBC driver
         Class.forName("com.mysql.jdbc.Driver");
         //STEP 3: Open a connection
         System.out.println("Connecting to a selected database...");
         conn = DriverManager.getConnection(DB_URL, USER, PASS);
         System.out.println("Connected database successfully...");
         //STEP 4: Execute a query
          System.out.println("Creating statement...");
          stmt = conn.createStatement();
          if(book! =null){
            try{
            String sql = "select * from library where category ="+category +" and catalog =" +catalog +"";
         stmt.executeQuery(sql);
          }catch(Exception e){
            System.out.println ("Category or catalog doesnot exist");
          }
          try{
            String sql = "insert into me(book) values ("+book+") from library where category ="+category +" and catalog =" +catalog +"";
           stmt.executeUpdate(sql);
           }catch(Exception e)(){
             System.out.println ("Book already exists ");
           }
   } else{
     try{
            String sql = "insert into(catalog, category )values ("+catalog +", "+category +") from library" ;
           stmt.executeUpdate(sql);
           }catch(Exception e)(){
             System.out.println ("Record already exists ");
           }
    
   }
  
}
public void search (String catalog, String author ){
    //JDBC driver name and database URL
    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
    static final String DB_URL = "jdbc:mysql://localhost/STUDENTS";
     // Database credentials
    static final String USER = "username";
     static final String PASS = "password";
      public static void main(String[] args) {
        Connection conn = null;
         Statement stmt = null;
         try{ //STEP 2: Register JDBC driver
         Class.forName("com.mysql.jdbc.Driver");
         //STEP 3: Open a connection
         System.out.println("Connecting to a selected database...");
         conn = DriverManager.getConnection(DB_URL, USER, PASS);
         System.out.println("Connected database successfully...");
         //STEP 4: Execute a query
          System.out.println("Creating statement...");
          stmt = conn.createStatement();
          if(author! =null){
          String sql = "select book, author from library where catalog ="+catalog +" and author like '"+author+"%'") ;
          ResultSet rs=stmt.executeQuery(sql);
          while (rs.next()){
            String book=rs.getString("book");
            String author=rs.getString("author ");
            int i=0
            System.out.println (++i +"."+book" author is "+author );
          }
    }else{
        String sql = "select catalog from library where catalog like'"+catalog +"%'") ;
          ResultSet rs=stmt.executeQuery(sql);
          while (rs.next()){
            String catalog =rs.getString("catalog ");
            int i=0
            System.out.println (++i +"."+catalog);
          }
     
    }
  
}



public static void main(String[] args) {
   
   Scanner sc=new Scanner(System.in);
  
  
  
   System.out.println("Please select the operation 1.Add item 2.Search 3.Return");

    example e = new example ();
    while(sc.nextInt()==1){
      System.out.println ("Search by 8. Catalog 9.Author Other numbers to quit") ;
      while(sc.nextInt()==8){
      System.out.println ("Please enter name of the catalogue");
     String name= sc. next();
     e.search(name,catalog);}
     System.out.println ("Search by 8. Catalog 9.Author Other numbers to quit") ;
     while(sc.nextInt()==9){
      System.out.println ("Please enter name of the author ");
     String name= sc. next();
     e.search(name,author);}
     System.out.println ("Search by 8. Catalog 9.Author Other numbers to quit");
     
    }
System.out.println("Please select the operation 1.Add item 2.Search ");

while(sc.nextInt()==2){
     System.out.println ("Add options 7.add catalog 8.add category 9.add books Other numbers to quit");
while(sc.nextInt()==8){
System.out.println ("enter category name to be added");
String category =sc.next();
System.out.println ("enter catalog name under which category "+category +" should be added") ;
String catalog =sc.next();
e.additem(category, catalog, null);
}
System.out.println ("Add options 7.add catalog 8.add category 9.add books Other numbers to quit");
while (sc.nextInt()==9){
   System.out.println ("enter book name to be added");
String book=sc.next();

System.out.println ("enter catalog name under which book "+book +" should be added") ;
String catalog =sc.next();

System.out.println ("enter category name under which book "+book +" should be added");
String category =sc.next();

e.additem(category, catalog, null);}
while(sc.nextInt()==7){
System.out.println ("enter catalog name to be added");
String catalog =sc.next();

e.additem(null, catalog, null);
}

}System.out.println("Please select the, operation 1.Add item 2.Search ");
}