Main Program (class name – Master) This class contains the main function and it acts as a key to access various other class and functions. import java.util.Scanner; import java.io.*; class master{ public void mains()throws IOException { System.out.println(" "); BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter:\n1 for Student functions\n2 for Account functions\n3 for library functions\n\n0 to quit the program.\nENTER YOUR CHOICE"); int choice=Integer.parseInt(in.readLine()); if(choice==1) { student_func(); } else if(choice==2) { account_func(); } else if(choice==3) { library_func(); } else if(choice==0) { System.out.println("Thank you for using this program"); } else if((choice!=0)&&(choice!=1)&&(choice!=2)&&(choice!=3)) { mains(); } } public void student_func()throws IOException {
1 © Saumya Priyam
System.out.println(" "); BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter:\n1 to view student list\n2 to add new student to records\n3 to submit fee of a student\n\n0 to go to the main menu\nENTER YOUR CHOICE"); int choice=Integer.parseInt(in.readLine()); if(choice==1) { student p=new student(); p.loaddata(); p.print_list(); student_func(); } else if(choice==2) { student p=new student(); p.loaddata(); p.new_student(); student_func(); } else if(choice==3) { fee_submission p=new fee_submission(); p.loadstudentdata(); p.new_transaction(); student_func(); } else if(choice==0) { mains(); } } public void account_func()throws IOException { System.out.println(" "); BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter:\n1 for account transaction\n2 fee submission of students\n3 to show Account Transactions and Balance\n4 to show fee transactions\n\n0 to go to the main menu\nENTER YOUR CHOICE");
2 © Saumya Priyam
int choice=Integer.parseInt(in.readLine()); if(choice==1) { account_transaction p=new account_transaction(); p.loadlastdata(); p.transaction_process(); account_func(); } else if(choice==2) { fee_submission p=new fee_submission(); p.loadstudentdata(); p.new_transaction(); account_func(); } else if(choice==3) { account p=new account(); p.loadaccntdata(); p.print_list(); account_func(); } else if(choice==4) { fee_data_retriver p=new fee_data_retriver(); p.loadfeedata(); System.out.println("Enter:\n1 to sort by class\n2 to sort by quarter\n3 to sort by student name and class\n4 to have unpicked list\nAny other numeric key to cancel the operation."); int h=Integer.parseInt(in.readLine()); if(h==4) p.print_list(); else if(h==1) { System.out.println("Enter the class"); String temp=in.readLine(); p.print_list_cls(temp); } else if(h==2) { System.out.println("Enter the quarter of the year"); int temp=Integer.parseInt(in.readLine()); p.print_list_qtr(temp);
3 © Saumya Priyam
} else if(h==3) { System.out.println("Enter the student name followed by class"); String temp1=in.readLine(); String temp2=in.readLine(); p.print_list_nc(temp1,temp2); } else if(h==4) { p.print_list(); } account_func(); } else if(choice==0) { mains(); } } public void library_func()throws IOException { System.out.println(" "); BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter:\n1 to Issue a book from Library\n2 to add new book to Library\n3 to show library book list\n4 to show history of books issued\n5 to return an issued booked\n6 to show history of books returned\n7 to show list of books yet to be returned\n\n0 to go to the main menu\nENTER YOUR CHOICE"); int choice=Integer.parseInt(in.readLine()); if(choice==1) { Book_Issue p=new Book_Issue(); p.initiate(); library_func(); } else if(choice==2) { library p=new library(); p.loadbookdata(); p.new_book(); library_func(); } else if(choice==3)
4 © Saumya Priyam
{ library p=new library(); p.loadbookdata(); p.print_list(); library_func(); } else if(choice==4) { Book_Issue p=new Book_Issue(); p.book_issue_list(); library_func(); } else if(choice==5) { return_library_book p=new return_library_book(); p.initiate(); library_func(); } else if(choice==6) { return_library_book p=new return_library_book(); p.book_return_list(); library_func(); } else if(choice==7) { yet_to_return p=new yet_to_return(); p.initiate(); library_func(); } else if(choice==0) { mains(); } } public static void main(String args[])throws IOException { System.out.println("Welcome!!!\n"); master m=new master(); m.mains(); } }
5 © Saumya Priyam
Student functions Class name – student This class contains the functions to access the records related to students. import java.util.*; import java.io.*; public class student { public String name[]=new String[100]; public String fthrname[]=new String[100]; public String mthrname[]=new String[100]; public String dob[]=new String[100]; public String doj[]=new String[100]; public String cls[]=new String[100]; public int recordcount; public void loaddata()throws IOException { BufferedReader in=new BufferedReader(new FileReader("students.txt")); String temp = in.readLine(); recordcount=0; int x=0; if(temp!=null) { for(int a=0;a
6 © Saumya Priyam
{ name[no]=k.substring(0,a); a++; t=a; break; } } for(a=a;a
7 © Saumya Priyam
} public void new_student()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter student name followed by Father's name, Mother's name,Date of Birth, Date of joining school and class of student"); String tnme=in.readLine(); String tfnme=in.readLine(); String tmnme=in.readLine(); String tdob=in.readLine(); String tdoj=in.readLine(); String tcls=in.readLine(); String t=tnme+";"+tfnme+";"+tmnme+";"+tdob+";"+tdoj+";"+tcls+"?"; byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("students.txt",true); fout.write(barr); System.out.println("Saved!!"); } public void print_list() { System.out.println("Name\t\t\tFather's Name\t\t\tMother's Name\t\t\tDate of Birth\t\tDate of Joining\t\tClass"); System.out.println("======================================================================== ===================================================="); for(int a=0;a
8 © Saumya Priyam
Class name – fee_submission This class saves the fee record of the student and also adds the transaction amount to the balance sheet of the school accounts section. import java.util.*; import java.io.*; public class fee_submission extends student { int indexno; int prebal; int a; public void loadstudentdata()throws IOException { BufferedReader in=new BufferedReader(new FileReader("accnt.txt")); String temp = in.readLine(); prebal=0; if(temp!=null) { for(int a=temp.length()-2;a>=0;a--) { if(temp.charAt(a)==';') { prebal=Integer.parseInt(temp.substring(a+1,temp.length()-1)); break; } } } } public void new_transaction()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); super.loaddata(); System.out.println("Enter Student name and class"); String studentname=in.readLine(); String studentclass=in.readLine(); for(a=0;a
10 © Saumya Priyam, ISC 2013
System.out.println("Record found! \nFather's Name: "+super.fthrname[a]+"\n\nEnter 1 to continue fee transaction or any other key to cancel fee transaction"); int l=Integer.parseInt(in.readLine()); if(l==1) { indexno=a; new_transactioncontinued(); } else System.out.println("Transaction canceled"); break; } } } public void new_transactioncontinued()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the fee amount, date and fee for which quarter of the month"); int feeamt=Integer.parseInt(in.readLine()); String s_date=in.readLine(); int qrtr=Integer.parseInt(in.readLine()); String desp="Fee: "+super.name[indexno]+","+super.cls[indexno]+",Q-"+qrtr; String t=desp+";"+s_date+";"+prebal+";"+feeamt+";"+(feeamt+prebal)+"?"; byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("accnt.txt",true); fout.write(barr); String tmp=super.name[indexno]+";"+super.cls[indexno]+";"+qrtr+";"+s_date+";"+feeamt+"?"; barr=tmp.getBytes(); FileOutputStream fout1=new FileOutputStream("stndtfee.txt",true); fout1.write(barr); System.out.println("Saved!!"); } }
11 © Saumya Priyam, ISC 2013
Accounts functions Class name – account_transaction Saves the transaction carried out by the school for various events. The transactions are divided into two Debit and Credit and the user is asked to select between them. Also stores the revenue generated by collection of fee as credit. import java.util.*; import java.io.*; public class account_transaction{ int prebal; public void loadlastdata()throws IOException { BufferedReader in=new BufferedReader(new FileReader("accnt.txt")); String temp = in.readLine(); prebal=0; if(temp!=null) { for(int a=temp.length()-2;a>=0;a--) { if(temp.charAt(a)==';') { prebal=Integer.parseInt(temp.substring(a+1,temp.length()-1)); break; } } } } public void new_credit_account()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Description of Transaction followed by Date and Amount"); String descp=in.readLine(); String date=in.readLine(); int amnt=Integer.parseInt(in.readLine()); String t=descp+";"+date+";"+prebal+";"+amnt+";"+(amnt+prebal)+"?"; byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("accnt.txt",true); fout.write(barr); System.out.println("Saved!!"); }
12 © Saumya Priyam, ISC 2013
public void new_debit_account()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter Description of Transaction followed by Date and Amount"); String descp=in.readLine(); String date=in.readLine(); int amnt=Integer.parseInt(in.readLine()); String t=descp+";"+date+";"+prebal+";"+amnt+";"+(prebal-amnt)+"?"; byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("accnt.txt",true); fout.write(barr); System.out.println("Saved!!"); } public void transaction_process()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter 1 for Debit, 2 for Credit."); int ch=Integer.parseInt(in.readLine()); loadlastdata(); if(ch==1) new_debit_account(); else if(ch==2) new_credit_account(); else System.out.println("Invalid Choice"); } }
13 © Saumya Priyam, ISC 2013
Class name- account This name displays the account transaction carried out by the school account section. import java.util.*; import java.io.*; class account{ String description[]=new String[100]; String date[]=new String[100]; String erstblnce[]=new String[100]; String amt[]=new String[100]; String newbal[]=new String[100]; int recordaccntcount; public void loadaccntdata()throws IOException { BufferedReader in=new BufferedReader(new FileReader("accnt.txt")); String temp = in.readLine(); recordaccntcount=0; int x=0; if(temp!=null) { for(int a=0;a
14 © Saumya Priyam, ISC 2013
} } for(a=a;a
15 © Saumya Priyam, ISC 2013
Class name – fee_data_retriver This class has functions to display the fee submitted by the student. It has capability to handle large data as data can be searched ad sorted by class of student, quarter of the year and student of a class. import java.util.*; import java.io.*; public class fee_data_retriver { String name[]=new String[1000]; String cls[]=new String[1000]; String fee[]=new String[1000]; String date[]=new String[1000]; int qrtr[]=new int[1000]; int feerecordcount; public void loadfeedata()throws IOException { BufferedReader in=new BufferedReader(new FileReader("stndtfee.txt")); String temp = in.readLine(); feerecordcount=0; int x=0; if(temp!=null) { for(int a=0;a
16 © Saumya Priyam, ISC 2013
a++; t=a; break; } } for(a=a;a
17 © Saumya Priyam, ISC 2013
String prce=in.readLine(); String t=bnme+";"+pdate+";"+q+";"+prce+"?"; byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("libbooks.txt",true); fout.write(barr); System.out.println("Saved!!"); } public void print_list() { System.out.println("Name\t\tClass\tQuarter\tDate\t\tAmount"); System.out.println("======================================================================== ========================================"); for(int a=0;a
18 © Saumya Priyam, ISC 2013
System.out.println("======================================================================== ========================================"); for(int a=0;a
19 © Saumya Priyam, ISC 2013
Library functions Class name – Book_Issue Class the issue book and display the list of books issued to students and it automatically manages the number of books present in the library. import java.io.*; import java.util.Scanner; public class Book_Issue extends student { String bookname[]=new String[1000]; String prcsdate[]=new String[1000]; int qnty[]=new int[1000]; String price[]=new String[1000]; int bookrecordcount; int libfilecount; public Book_Issue()throws IOException { BufferedReader n=new BufferedReader(new FileReader("countred.txt")); String temp3= n.readLine(); libfilecount=0; if(temp3!=null) { for(int a=temp3.length()-2;a>=0;a--) { if(temp3.charAt(a)==';') { libfilecount=Integer.parseInt(temp3.substring(a+1,temp3.length()-1)); break; } } } BufferedReader in=new BufferedReader(new FileReader("libbooks"+libfilecount+".txt")); String temp = in.readLine(); bookrecordcount=0; int x=0; if(temp!=null) { for(int a=0;a
20 © Saumya Priyam, ISC 2013
bookrecordcount++; x=a+1; } } } } public void distributebookdata(String k,int no) { int t=0; int a=0; for(a=0;a
21 © Saumya Priyam, ISC 2013
public void initiate()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the number of books to be issued"); int count=Integer.parseInt(in.readLine()); for(int p=0;p
22 © Saumya Priyam, ISC 2013
if(bookfnd==0) System.out.println("Book not found"); } else System.out.println("No student with this name and class found!"); } String temp2=""; for(int y=0;y
23 © Saumya Priyam, ISC 2013
Class name – library Class to add new books to library and it displays the available books in the library. import java.io.*; public class library{ String bookname[]=new String[1000]; String prcsdate[]=new String[1000]; String qnty[]=new String[1000]; String price[]=new String[1000]; int bookrecordcount; public void loadbookdata()throws IOException { BufferedReader n=new BufferedReader(new FileReader("countred.txt")); String temp2= n.readLine(); int libfilecount=0; for(int a=temp2.length()-2;a>=0;a--) { if(temp2.charAt(a)==';') { libfilecount=Integer.parseInt(temp2.substring(a+1,temp2.length()-1)); break; } } BufferedReader in=new BufferedReader(new FileReader("libbooks"+libfilecount+".txt")); String temp = in.readLine(); bookrecordcount=0; int x=0; if(temp!=null) { for(int a=0;a
24 © Saumya Priyam, ISC 2013
int a=0; for(a=0;a
25 © Saumya Priyam, ISC 2013
for(int a=temp2.length()-2;a>=0;a--) { if(temp2.charAt(a)==';') { libfilecount=Integer.parseInt(temp2.substring(a+1,temp2.length()-1)); break; } } byte barr[]=t.getBytes(); FileOutputStream fout=new FileOutputStream("libbooks"+libfilecount+".txt",true); fout.write(barr); System.out.println("Saved!!"); } public void print_list() { System.out.println("Book Name\t\tDate of Purchase\t\tQuantity\t\tPrice"); System.out.println("======================================================================== ========================================"); for(int a=0;a
26 © Saumya Priyam, ISC 2013
Class name – return_library_book Consists of functions to allow the computer to save data related to returning book to the library and displays the history of books returned. import java.io.*; import java.util.Scanner; public class return_library_book { String bookname[]=new String[1000]; String prcsdate[]=new String[1000]; int qnty[]=new int[1000]; String price[]=new String[1000]; int bookrecordcount; int libfilecount; String studentname[]=new String[1000]; String cls[]=new String[1000]; String dateissue[]=new String[1000]; String bookname2[]=new String[1000]; int issuecount; public return_library_book()throws IOException { BufferedReader n=new BufferedReader(new FileReader("countred.txt")); String temp3= n.readLine(); libfilecount=0; for(int a=temp3.length()-2;a>=0;a--) { if(temp3.charAt(a)==';') { libfilecount=Integer.parseInt(temp3.substring(a+1,temp3.length()-1)); break; } } BufferedReader in=new BufferedReader(new FileReader("libbooks"+libfilecount+".txt")); String temp = in.readLine(); bookrecordcount=0; int x=0; if(temp!=null) { for(int a=0;a
27 © Saumya Priyam, ISC 2013
if(temp.charAt(a)=='?') { distributelibbookdata(temp.substring(x,a),bookrecordcount); bookrecordcount++; x=a+1; } } } BufferedReader i=new BufferedReader(new FileReader("libbookissuelist.txt")); String temp2 = i.readLine(); issuecount=0; int u=0; if(temp2!=null) { for(int a=0;a
28 © Saumya Priyam, ISC 2013
a++; t=a; break; } } for(a=a;a
29 © Saumya Priyam, ISC 2013
{ if(k.charAt(a)==';') { dateissue[no]=k.substring(t,a); a++; t=a; break; } } bookname2[no]=k.substring(t,k.length()); } public void initiate()throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the number of books to be returned"); int count=Integer.parseInt(in.readLine()); for(int p=0;p
30 © Saumya Priyam, ISC 2013
} } if(fnd==0) System.out.println("Issue record not found in history!"); } else System.out.println("Book already returned"); } String temp2=""; for(int y=0;y
31 © Saumya Priyam
Class name – yet_to_return Displays list of books that are issued to the students and are yet to be returned to the library. import java.io.*; import java.util.Scanner; public class yet_to_return { String studentname[]=new String[1000]; String cls[]=new String[1000]; String issuedate[]=new String[1000]; String bookname[]=new String[1000]; int recordcount; public yet_to_return()throws IOException { BufferedReader n=new BufferedReader(new FileReader("libbookissuelist.txt")); String temp2= n.readLine(); recordcount=0; int x=0; if(temp2!=null) { for(int a=0;a
32 © Saumya Priyam
} } for(a=a;a
33 © Saumya Priyam
Class name – return_check Class that checks whether a given book name has been returned by the student. import java.io.*; import java.util.Scanner; public class return_check { String studentname[]=new String[1000]; String cls[]=new String[1000]; String issuedate[]=new String[1000]; String bookname[]=new String[1000]; String returndate[]=new String[1000]; int recordcount; public return_check()throws IOException { BufferedReader n=new BufferedReader(new FileReader("libbookreturnlist.txt")); String temp2= n.readLine(); recordcount=0; int x=0; if(temp2!=null) { for(int a=0;a
34 © Saumya Priyam
break; } } for(a=a;a
35 © Saumya Priyam
rtrndate=returndate[a]; } return(rtrndate); } }
36 © Saumya Priyam