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

Idea Libraries usually face problems with managing their books and keeping track

ID: 3842157 • Letter: I

Question

Idea Libraries usually face problems with managing their books and keeping track with who is borrowing and who is supposed to return the books. Our program will keep track of the books, students and when they should return them. Organizing them according to ID numbers, names of book and author's name. Each student will have 15 days to return the book from the initial date How will it work? The program will have a class called student, which will have the name of the student, their ID number and the book they borrowed as a parameter. Another class will be the books class, containing the name, author and ID number of the book. Several functions will be designed to add and remove students from the system by the admins. The books and students' data will be stored in an external text file. There will be several types of books, each type will be available for either the students or the professors only.

Explanation / Answer

\The following program is for library management system
\About_it.txt text file name for input file name.....

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import java.sql.*;
import java.util.*;


public class MyLibrarian
{
static JFrame fr2,fr3,fr4,fr5,fr6,fr7,fr8,fr9,fr10,fr11,fr12,fr13,fr14;
static JPanel p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14;
JButton LOGIN=new JButton("LOGIN");
JButton ADD,AddNewBook,DELETE,DelOldBook,ADDNEWUSER,AddThisUser,DELEXISTUSER,DelThisUser,CHANGEPW;
JButton MARKEOI,CHANGEMYPW,QUERY,RUNQUERY,REPORT,ISSUE_BOOK,ADD_BORROWER,AddThisBorrower;
JButton CLOSE_BORROWER,CloseThisBorrower,VIEW_REC,MODIFY_REC,showItButton;
JLabel jLabel, jLabel1, jLabel2,l1,l2,l3,l4,l5,l6,l7,l8,l9,l10;
JTextField section,bookname,author,price,availcode,currentborrower,serno,boname,boaddress;
JTextField bophoneno,borrowerNewMagazine,borrowerPhoneNo,borrowerLastMagazine;
JPasswordField loginname,loginpass,oldpw,newpw,newpwc;
JTextField username,password,Designation,loginpassback,usrname,fboserial;
JTextField borrowerSerialno,borrowerName,borrowerAddress,borrowerLastBook,borrowerStatus;
JTextField borrowerNewBook;
//JTextField loginname = new JTextField(20);  
//JTextField loginpass = new JTextField(20);  
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
String t1;
String url="jdbc:odbc:BANK";
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String sql,sq,sqUsr,sbookd,sdUsr,squpdate,dialogmessage,serialno,squpdate_book,squpdate_mag;
int dialogtype = JOptionPane.PLAIN_MESSAGE;
String dialogs = "SUCCESS";
String dialogf = "FAILURE";
String dialogd = "DELETION OK ?";
String dialogw = "WARNING !!!";
DefaultTableModel defaulttablemodel = new DefaultTableModel();
boolean DelFlag,AddFlag,DelUsrFlag,AddUsrFlag;
Font dataFont = new Font("times new roman",Font.PLAIN,15);
String loginnameback;
//GregorianCalendar gCal;

public static void main(String[] args)
   {
       MyLibrarian c1=new MyLibrarian();
   }

public MyLibrarian()
   {
       //setupMenuBar();
       login();
   }

   void addnewbook()

   {
   fr3=new JFrame(" My Librarian v1.0 Add-Book ");
fr3.setVisible(true);
   fr3.setSize(600,300);
   //fr3.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

   p3=new JPanel();
   p3.setLayout(gridbag);

//serialno=new JTextField(5);
   section=new JTextField(10);
   bookname=new JTextField(30);
   author=new JTextField(30);
   price=new JTextField(20);
   availcode=new JTextField(1);
   currentborrower=new JTextField(30);

/*l1=new JLabel("Serial No ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=0;
       gridbag.setConstraints(l1,c);
       p3.add(l1,c);
     
   serialno= new JTextField(" ");
   c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=0;
       gridbag.setConstraints(serialno,c);
       p3.add(serialno);*/  

   l2=new JLabel("Section ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=1;
       gridbag.setConstraints(l2,c);
       p3.add(l2,c);

   section= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=1;
       gridbag.setConstraints(section,c);
       p3.add(section);


   l3=new JLabel("Book Name ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=2;
       gridbag.setConstraints(l3,c);
       p3.add(l3,c);

   bookname= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=2;
       gridbag.setConstraints(bookname,c);
       p3.add(bookname);


   l4=new JLabel("Author ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=3;
       gridbag.setConstraints(l4,c);
       p3.add(l4,c);

   author= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=3;
       gridbag.setConstraints(author,c);
       p3.add(author);


   l5=new JLabel("Price ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=4;
       gridbag.setConstraints(l5,c);
       p3.add(l5,c);

   price= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=4;
       gridbag.setConstraints(price,c);
       p3.add(price);


   l6=new JLabel("Avail Code ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=5;
       gridbag.setConstraints(l6,c);
       p3.add(l6,c);

   availcode= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=5;
       gridbag.setConstraints(availcode,c);
       p3.add(availcode);


   l7=new JLabel("Current Borrower ");
   c.ipady=2;
       c.ipadx=2;
       c.anchor=GridBagConstraints.WEST;
       c.gridx=0;
       c.gridy=6;
       gridbag.setConstraints(l7,c);
       p3.add(l7,c);

   currentborrower= new JTextField(" ");
       c.ipady=2;
       c.ipadx=2;
       c.gridx=1;
       c.gridy=6;
       gridbag.setConstraints(currentborrower,c);
       p3.add(currentborrower);

   AddNewBook = new JButton("ADD THIS BOOK");
           c.ipady = 2;                       
                   c.ipadx = 2;                       
           c.weighty = 0.0;                       
           c.anchor = GridBagConstraints.CENTER;   
                   c.gridwidth = 1;                       
           c.gridx = 0;                       
           c.gridy = 7;                       
           gridbag.setConstraints(AddNewBook, c);
       p3.add(AddNewBook);                                      
               AddNewBook.addActionListener(new ButtonHandler());


   fr3.getContentPane().add(p3);
   JFrame.setDefaultLookAndFeelDecorated(true);
   }

void UpdateBorrowerRecord()

   {
       try
       {

           Class.forName(driver);
           Connection connection=DriverManager.getConnection(url);
           Statement statement = connection.createStatement();

           String query = "SELECT * FROM borrower_record";
           ResultSet rs = statement.executeQuery(query);
           boolean hasResults = statement.execute(query);

                   if(hasResults)
                   {
                   ResultSet result = statement.getResultSet();
                       if(result!=null)
                       {   
                               Update_BorrowerDB();
                      }
                       connection.close();
                   }              
           }
           catch(Exception ex)
           {

           }

       }  

void Update_BorrowerDB()
{

   try
   {
                           String temp = borrowerSerialno.getText();
                           temp = temp.trim();                          
                           String temp1 = borrowerNewBook.getText();
           temp1 = temp1.trim();
                           String temp2 = borrowerNewMagazine.getText();
                               temp2 = temp2.trim();
                           String temp5 = borrowerStatus.getText();
                           temp5 = temp5.trim();
                       int foundclosedrec = 0;


                           System.out.println(temp5);

                       if (temp5.equals("C"))
                       {
                               foundclosedrec = 1;
                               dialogmessage = "Cannot Update.Closed Record";
                               dialogtype = JOptionPane.INFORMATION_MESSAGE;
                               //show message
                               JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogf,dialogtype);
                               return;
                       }

                       //System.out.println(temp);
                           //System.out.println(temp1);
                           //System.out.println(temp2);

                           if (foundclosedrec==0)
                           {
                           squpdate_book = "UPDATE borrower_record SET bolastbook='"+temp1+"' WHERE boserial = '"+temp+"'";
                           squpdate_mag = "UPDATE borrower_record SET bolastmagazine='"+temp2+"' WHERE boserial = '"+temp+"'";
                           Class.forName(driver);
                          Connection connection=DriverManager.getConnection(url);
                          Statement statement = connection.createStatement();
                           statement.executeUpdate(squpdate_book);  
                           statement.executeUpdate(squpdate_mag);
                          connection.close();

                           dialogmessage = "Borrower Record Updated";
                           dialogtype = JOptionPane.INFORMATION_MESSAGE;
                           //show message
                           JOptionPane.showMessageDialog((Component) null, dialogmessage, dialogs,dialogtype);

                           borrowerNewBook.setText("");
                           borrowerNewMagazine.setText("");

                           }

                           fr14.setVisible(false);
                           ISSUE_BOOK();

   }

   catch(Exception ex)
           {
                  
           }  
          

       }      


void getDate()
       {
       Calendar cal = Calendar.getInstance(TimeZone.getDefault());
       String DATE_FORMAT="dd-MM-yyyy";
       java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
       sdf.setTimeZone(TimeZone.getDefault());
       //System.out.println("Now : "+sdf.format(cal.getTime()));
       String t1 = sdf.format(cal.getTime());
       }


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote