0% found this document useful (0 votes)
3 views29 pages

Book Purchase and Return System

This document describes a Java program for a library management system. The program allows users to buy, return, or borrow books from different genres. It stores book details like titles, prices, and genres in arrays. Users can navigate through menu options to select books and the program tracks the total cost of purchases.

Uploaded by

TRICK SHOT
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views29 pages

Book Purchase and Return System

This document describes a Java program for a library management system. The program allows users to buy, return, or borrow books from different genres. It stores book details like titles, prices, and genres in arrays. Users can navigate through menu options to select books and the program tracks the total cost of purchases.

Uploaded by

TRICK SHOT
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

*;

public class practicals

int p1,p,i,a;static int to=0;

static String S="";

String[] s= {"The Necklace","The Lottery","An Occurance","To Build A Fire","Araby","The


Bet","The Swimmer","Cat Person"};

String[] fi={"1984","Great Gatsby","The Alchemist","Pride and Prejudice","Beloved","The


Road","Catch-22","The Bell Jar"};

String[] b= {"Steve Jobs","Becoming","Long Walk To Freedom","Alexander Hamilton","A


Promised Land","Wings Of Fire","Born A crime","Untamed"};

String[] c= {"Bossypants","Yes Please","Good Omens","Lucky Jim","Dear Girls","The


Bedwetter","Scoop","Modern Romance"};

String[] fa= {"The Way Of Kings","The Name Of The Winds","The Lord Of The Rings","A Game Of
Thrones","The Fifth Season","The Eye Of The World","Six Of Crows","American Gods"};

String[] h= {"The Shining","Dracula","It","Ghost Story","The Exorcist","Hell House","Bird


Box","Frankenstein"};

String[] t= {"Gone Girl","The Guest List","Behind Closed Doors","Da Vinci


Code","Falling","Verity","Misery","Sharp Objects"};

String[] n= {"Jane Eyre","To Kill A Mockingbird","Ulysses","War and Peace","Brave New


World","Lord Of The Flies","Alice In Wonderland","Middlemarch"};

int[] a1={770,999,1444,842,546,782,577,2500};

int[] a2={1414,552,894,4572,1001,5253,1545,545};

int[] a3={5456,894,2541,250,5420,4587,991,545};

int[] a4={154,998,1111,2051,2200,2020,2021,454};

int[] a5={1999,1987,5454,9875,3254,2541,7889,878};

int[] a6={584,955,475,896,1345,1234,439,966};

int[] a7={2222,6548,7825,4569,1440,512,250,524};

int[] a8={545,354,655,2054,2030,2105,5010,};

Scanner sc=new Scanner([Link]);


void buy()

[Link]("What book do u want to buy?");

[Link]("1. Fiction");

[Link]("2. Short Stories");

[Link]("3. Biography");

[Link]("4. Comedy");

[Link]("5. Fantasy");

[Link]("6. Horror");

[Link]("7. Thriler");

[Link]("8. Novels");

[Link]("Enter your choice");

p=[Link]();

if(p==1)

fiction();

else if(p==2)

shorts();

else if(p==3)

biography();

else if(p==4)

comedy();
}

else if(p==5)

fantasy();

else if(p==6)

horror();

else if(p==7)

thriller();

else if(p==8)

novel();

else

exit();

[Link]("Do u want to go back to menu? 1 if Yes and 2 if No");

p=[Link]();

if(p==1)

entry();

else

exit();
}

void booksreturn()

[Link]("What book do u want to return?");

[Link]("1. Fiction");

[Link]("2. Short Stories");

[Link]("3. Biography");

[Link]("4. Comedy");

[Link]("5. Fantasy");

[Link]("6. Horror");

[Link]("7. Thriler");

[Link]("8. Novels");

[Link]("Enter your choice");

p=[Link]();

if(p==1)

fiction();

else if(p==2)

shorts();

else if(p==3)

biography();

}
else if(p==4)

comedy();

else if(p==5)

fantasy();

else if(p==6)

horror();

else if(p==7)

thriller();

else if(p==8)

novel();

else

exit();

[Link]("Do u want to go back to menu? 1 if Yes and 2 if No");

p=[Link]();

if(p==1)

entry();
else

exit();

void borrow()

[Link]("What book do u want to borrow?");

[Link]("1. Fiction");

[Link]("2. Short Stories");

[Link]("3. Biography");

[Link]("4. Comedy");

[Link]("5. Fantasy");

[Link]("6. Horror");

[Link]("7. Thriler");

[Link]("8. Novels");

[Link]("Enter your choice");

p=[Link]();

if(p==1)

fiction();

else if(p==2)

shorts();

else if(p==3)
{

biography();

else if(p==4)

comedy();

else if(p==5)

fantasy();

else if(p==6)

horror();

else if(p==7)

thriller();

else if(p==8)

novel();

else

exit();

[Link]("Do u want to go back to menu? 1 if Yes and 2 if No");


p=[Link]();

if(p==1)

entry();

else

exit();

void exit()

[Link]("----------------------------------------------------------------------------------------------------");

[Link]("\t\t\t\tJoy Of Books Library");

[Link]("\t\t\t\t88,5th Main Rd, Block V,\n \t\t\t\tAnna Nagar,Chennai,\n\t\t\t\tTamil


Nadu-600040");

[Link](S+"\t"+"\t");

if(p1==2)

[Link]("Here is your money back:"+"\u20B9"+to);

[Link]("\t\t\t\tThank u come again!!!");

[Link]("----------------------------------------------------------------------------------------------------");

else

[Link]("Total cost:"+"\u20B9"+to);

[Link]("Thank u come again!!!");

[Link]("----------------------------------------------------------------------------------------------------");

void entry()
{

practicals ob=new practicals();

[Link]("Welcome to the Joy Of Books library!");

[Link]("If you want to buy, return or just to borrow a book, you have come to the right
place!");

[Link]("1. Buy");

[Link]("2. Return");

[Link]("3. Borrow");

[Link]("4. Exit");

p1=[Link]();

if(p1==1)

[Link]();

else if(p1==2)

[Link]();

else if(p1==3)

[Link]();

else

[Link]();
}

void fiction()

for(i=0;i<=7;i++)

[Link](fi[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=fi[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==3)
{

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==7)

{
a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a1[a]);

to=a1[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a1[a]);

else

exit();

void shorts()

for(i=0;i<=7;i++)

[Link](s[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=s[a-1];

if(a==1)

a--;
[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);


to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a2[a]);

to=a2[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a2[a]);

else

exit();

}
void biography()

for(i=0;i<=7;i++)

[Link](b[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=b[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;
[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);


}

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a3[a]);

to=a3[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a3[a]);

else

exit();

void comedy()

for(i=0;i<=7;i++)

[Link](c[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=c[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

}
else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==6)
{

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a4[a]);

to=a4[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a4[a]);

else

exit();

void fantasy()

for(i=0;i<=7;i++)

{
[Link](fa[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=fa[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==4)

a--;
[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);

to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a5[a]);


to=a5[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a5[a]);

else

exit();

void horror()

for(i=0;i<=7;i++)

[Link](h[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=h[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;
[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);


}

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a6[a]);

to=a6[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a6[a]);

else

exit();

void thriller()

for(i=0;i<=7;i++)

[Link](t[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=t[a-1];
if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==3)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==5)
{

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a7[a]);

to=a7[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a7[a]);

else

{
exit();

void novel()

for(i=0;i<=7;i++)

[Link](n[i]);

[Link]("Enter the number of the book you want");

a=[Link]();

S=n[a-1];

if(a==1)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==2)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==3)

a--;
[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==4)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==5)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==6)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==7)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);


to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else if(a==8)

a--;

[Link]("It costs:"+"\u20B9"+ a8[a]);

to=a8[a]+to;

[Link]("The book's name:"+S+"\t\t\t"+a8[a]);

else

exit();

public static void main(String[]args)

practicals ob=new practicals();

[Link]();

You might also like