0% found this document useful (0 votes)
41 views

18 Project On Library Management

This document contains code for a library management system in Java. It defines a Record class to store book details like title, author, subject, and number of copies. An array of Record objects is created to store details of 20 books. The main method displays a menu to search for books by title, author or subject. If a match is found, it allows issuing or submitting that book and updates the number of copies. This continues in a loop until the user enters 5 to quit.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

18 Project On Library Management

This document contains code for a library management system in Java. It defines a Record class to store book details like title, author, subject, and number of copies. An array of Record objects is created to store details of 20 books. The main method displays a menu to search for books by title, author or subject. If a match is found, it allows issuing or submitting that book and updates the number of copies. This continues in a loop until the user enters 5 to quit.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 7

/* 18 Project on Library Management */ import java.io.*; import java.lang.

*; class Record { String title; String author; String subject; public int no; Record(String t,String a,String s,int n) { title=t; author=a; subject=s; no=n; } void show() { System.out.println(); System.out.println("Title : "+title); System.out.println("Author Name : "+author); System.out.println("Subject : "+subject); System.out.println("No. of books : "+no); } void display() { System.out.println("Book Name :"+title); System.out.println("Author Name :"+author); System.out.println("Subject :"+subject); System.out.println("No of book :"+no); } }

class lib_mngt { public static void main(String args[]) { Record obj[]=new Record[20]; int i,j; int ch=0; int temp=0; int g=0; String s=""; int y=0; int np=0; DataInputStream d=new DataInputStream(System.in); obj[0]=new obj[1]=new obj[2]=new obj[3]=new obj[4]=new obj[5]=new obj[6]=new Shell",25); Record("Java","Balguru","Java Pro",25); Record("OS","Galvin","Process",25); Record("AMP","AK Ray","Microprocessor",25); Record("NM","Zacker","Network",25); Record("CS","Fliger","Security",25); Record("SE","Presman","Software Engg",25); Record("Operating Sys","Yashwant","Unix

obj[7]=new Record("IBM-PC","Peter Abel","Assembly Lang",25); obj[8]=new Record("MS. DOS","Ray Duncan ","Programming",25); obj[9]=new Record("Principles of CS","Chuck","Computer Security",25); obj[10]=new Record("Security Principles","William","Cryptography",25); obj[11]=new Record("OOP","C Thomas","OO Programng",25); obj[12]=new Record("Java","Cohoon","Program design",25); obj[13]=new Record("Unix Concepts and Programming","Murugan Sethuraman","Unix Pro",25); obj[14]=new Record("Software Engineering Principles and Practice","Waman S. Jawadekar ","Engineering Principles",25); obj[15]=new Record("Java2 Programming","Keyur Shah ","java",25); obj[16]=new Record("Computer Security Basics","G.T.Gangenisr ","Security Basics",25); obj[17]=new Record("Auto Car India","Times","Car",25); 2

obj[18]=new Record("Elec for You","E","Electronics",25); obj[19]=new Record("Witch of Portobello","Paulo Ceolho","Novel",25); do { System.out.println("\t\t\t\t\tBook Details"); System.out.println("---------------------------------------------------------------------------------------------------\n"); for(i=0;i<20;i++) { obj[i].show(); } try { System.out.println("---------------------------------------------------------------------------------------------------\n"); System.out.print("Enter the Title / Author / Subject name to search :"); s=d.readLine(); }//end of try catch(Exception e) { System.out.println("I/O Error"); }//end of catch System.out.println(); System.out.println(s+" : Book Details");

for(i=0;i<20;i++) { if(obj[i].title.equalsIgnoreCase(s)|| obj[i].author.equalsIgnoreCase(s)|| obj[i].subject.equalsIgnoreCase(s)) { obj[i].display(); 3

temp=i; np=i; g=1; break; }//end of if else { g=0; } }//end of for switch(g) { case 1: try { System.out.println(); System.out.print("Press 1 to Issue & 2 to Submit the book:"); ch=Integer.parseInt(d.readLine()); } catch(Exception e) { } int q=np; j=temp; if(ch==1) { if(obj[j].no<=0) System.out.println("You can't issue"); else obj[j].no--; obj[j].display();

} else if(ch==2) { if(obj[j].no>=25) { System.out.println("you can not submit"); 4

} else { obj[i].no++; obj[j].display(); } } else System.out.println("Invalid Entery"); break; case 0: System.out.println("No Record Found"); break; }//end of switch; try { System.out.println(); System.out.print("Press 5 to continue : "); y=Integer.parseInt(d.readLine()); } catch(Exception e) { System.out.println("I/O Error"); } }while(y==5); }//end of main }//end of class

Output Book Details

Book Search

Issue & Submit option

You might also like