This program cannot store the previous record. Can someone help me tosolve this problem?Anyone there have source code of library system? import java.lang.*;import java.io.*;class ClearScr{public static void clrscr(){for(int cnt=0; cnt<=24; cnt++){System.out.println();}}}class BooksInfo{public String Btitle;public String Bisbn;public String Bauthor;public String name;public String date;public String Rdate;public String status;public String status2;public void includeBooks()throws java.io.IOException{InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);System.out.println("\n\n\n\n\n\n");System.out.println("***********************");System.out.println(" Book Shop");System.out.println("***********************");System.out.println("\n");System.out.println("Book in the Catalog");System.out.println("================================================================================");System.out.println("");System.out.println("");System.out.print(" Enter Author'sName :");Bauthor = in.readLine();System.out.print(" Enter the Title of theBook :");Btitle = in.readLine();System.out.print(" Enter the ISBN of theBook :");Bisbn = in.readLine();System.out.print(" Enter Book Status(in/out) :");status = in.readLine();System.out.println();}public void borrowBooks()throws java.io.IOException{InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);System.out.println("\n\n\n\n\n\n");System.out.println(" ***********************");System.out.println(" Book Shop");System.out.println(" ***********************");System.out.println("\n");System.out.println("\t\t\t*** Check OutBooks ***");System.out.println("\t\t\t---------------------\n");System.out.print("\t\t\tMember'sName : ");name = in.readLine();System.out.print("\t\t\tRent Date : ");date = in.readLine();System.out.print("\t\t\tDue Date : ");Rdate = in.readLine();}public void returnBooks()throws java.io.IOException{InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);System.out.println("\t PLEASE KeyIn (in) forretun book || (out) for no return book");System.out.println("\n");System.out.print("\t Enter Book Status(in/out) :");status2 = in.readLine();}public void DisplayBooks()throws java.io.IOException{System.out.println("\t\t\tTitle : "+ Btitle);System.out.println("\t\t\tISBN : "+ Bisbn);System.out.println("\t\t\tAuthor: "+ Bauthor);System.out.println("\t\t\tRent Date : "+ date);System.out.println("\t\t\tDue Date : "+ Rdate);System.out.println("\t\t\tBook Status : "+status);System.out.println("\t\t\tMember's Name : "+name);System.out.println();}}class Options{int total;String QtyOfBooks ="";String name2;String name ="";String date ="";String Rdate ="";String status ="";String status2 ="";boolean inputCorrect = true;BooksInfo[] bk = new BooksInfo[3];public void option1()throws java.io.IOException{ClearScr.clrscr();System.out.println("\t\t\t*** Include Books ***");System.out.println("\t\t\t---------------------\n");System.out.print("\t\t\tEnter Quantity ofBooks :");InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);QtyOfBooks = in.readLine();total = Integer.parseInt(QtyOfBooks);System.out.println();if(total <= bk.length){for(int cnt=0; cnt<total; cnt++){bk[cnt] = new BooksInfo();bk[cnt].includeBooks();}}}public void option2()throws java.io.IOException{ClearScr.clrscr();System.out.println("\t\t\t*** Check Out Books***");System.out.println("\t\t\t---------------------\n");System.out.print("\t\t\tEnter Quantity ofBooks :");InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);QtyOfBooks = in.readLine();total = Integer.parseInt(QtyOfBooks);System.out.println();if(total <= bk.length){for(int cnt=0; cnt<total; cnt++){bk[cnt] = new BooksInfo();bk[cnt].borrowBooks();bk[cnt].includeBooks();}}}public void option3()throws java.io.IOException{ClearScr.clrscr();System.out.println("\n\t\t\t*** Return Books***\n");System.out.println("\t\t\t------------------------\n");System.out.print("\t\t\tEnter Member's Name: ");InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);name2 = in.readLine();System.out.println();for(int cnt=0; cnt<total; cnt++){if(bk[cnt].name.equals(name2)){System.out.println("\t\t\tMember's name : "+bk[cnt].name);System.out.println("\n");System.out.println("\t\t\tISBN : "+bk[cnt].Bisbn);System.out.println("\t\t\tTitle : "+bk[cnt].Btitle);System.out.println("\n");System.out.println("\t\t\tRentDate : "+bk[cnt].date);System.out.println("\t\t\tDueDate : "+bk[cnt].Rdate);System.out.println("\n");System.out.println();}}if(total <= bk.length){for(int cnt=0; cnt<total; cnt++){bk[cnt] = new BooksInfo();bk[cnt].returnBooks();}}System.out.print("Press enter to continues");in.readLine();}public void option4()throws java.io.IOException{ClearScr.clrscr();System.out.println("\n\t\t\t*** Display BooksStatus ***\n");System.out.println("\t\t\t---------------------------------\n");for(int cnt=0; cnt<total; cnt++){bk[cnt].DisplayBooks();}System.out.print("\t\t\tPress enter to continues");InputStreamReader ir = new InputStreamReader(System.in);BufferedReader in = new BufferedReader(ir);in.readLine();}
You should use database or file to store the book info when a useradd a book. Otherwise when the program exit, nothing will exist. Youcan find example in java.sun.com.
When u add the entries on run times normally that data is not for presistantlike it is placed in ram there it can't be stored permannet and it'll be vanishas ur program exit and for that it is more appropriate to use databases at theback end. it is not difficult there r just like 7 or 8 commands and u'll able tostore data. and you have to use java.sql package for that take a look at itshelp it will me very usefull to you.
Is the code for schooling or for work? If work, thenyou need a decend database to contain your data anduse java.sql manipulated it. If school, then create a.txt file to contain your data. Li was very closedwhen responding to you.