You are on page 1of 7

/* 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);
}
}

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;

DataInputStream d=new DataInputStream(System.in);

obj[0]=new Record("Java","Balguru","Java Pro",25);


obj[1]=new Record("OS","Galvin","Process",25);
obj[2]=new Record("AMP","AK Ray","Microprocessor",25);
obj[3]=new Record("NM","Zacker","Network",25);
obj[4]=new Record("CS","Fliger","Security",25);
obj[5]=new Record("SE","Presman","Software Engg",25);
obj[6]=new Record("Operating Sys","Yashwant","Unix
Shell",25);

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

5
Output

Book Details

Book Search

6
Issue & Submit option

You might also like