Professional Documents
Culture Documents
import java.io.*;
import java.lang.*;
class Record
{
String title;
String author;
String subject;
public int no;
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);
}
}
1
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;
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)
}
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
5
Output
Book Details
Book Search
6
Issue & Submit option