From 6df5f850c7399e80bce2e75999999775a6766b87 Mon Sep 17 00:00:00 2001 From: Shubh Agrawal Date: Fri, 2 Oct 2020 11:17:30 +0530 Subject: [PATCH] fixed errors --- LIBRARY.CPP | 758 ++++++++++++++++++++++++++-------------------------- 1 file changed, 379 insertions(+), 379 deletions(-) diff --git a/LIBRARY.CPP b/LIBRARY.CPP index 0b502c4..6cad83a 100644 --- a/LIBRARY.CPP +++ b/LIBRARY.CPP @@ -1,481 +1,481 @@ /* HEADER FILES */ -#include -#include -#include -#include +#include +#include +#include // For strcmp method +using namespace std; /* CLASS USED */ class Book { protected: - char bookname[50]; - char author[50]; - char category[20]; + char bookname[50]; + char author[50]; + char category[20]; + public: - char refno[10]; - void CreateBook(); - void ShowBook(); + char refno[10]; + void CreateBook(); + void ShowBook(); }; void Book::CreateBook() { -cout<<"\n Enter Book Reference Number.."; -gets(refno); -cout<<"\n Enter Book Name.."; -gets(bookname); -cout<<"\n Enter Author's name.."; -gets(author); -cout<<"\n Enter Category.."; -gets(category); + cout << "\n Enter Book Reference Number.."; + gets(refno); + cout << "\n Enter Book Name.."; + gets(bookname); + cout << "\n Enter Author's name.."; + gets(author); + cout << "\n Enter Category.."; + gets(category); } void Book::ShowBook() { -cout<<"\n Book Number - "<>noofbook; + cout << "\n Enter Card No..."; + gets(cardno); + cout << "\n Enter Name of Person..."; + gets(name); + cout << "\n Enter No of Book Issued.."; + cin >> noofbook; } void Person::Show() { - cout<<"\n Card No - "<>cn; -cout<<"\n Enter Book Reference no.."; -cin>>bn; -f1.open("Person",ios::in|ios::binary); -f2.open("Book",ios::in|ios::binary); -f3.open("temp",ios::out|ios::binary); -while(f1.read((char*)&P,sizeof(Person)) && found==0) -{ - if(strcmpi(P.cardno,cn)==0) - { - found=1; - if(P.noofbook==0) - { - while(f2.read((char*)&B,sizeof(Book))&&flag==0) - { - if(strcmpi(B.refno,bn)==0) - { - P.noofbook++; - flag=1; -cout<<"\n Book issued Succesfully !!!"; -cout<<"\n Write Current Date in backside of book and submit within 20 days."; -cout<<"\n Otherwise fine of Rs.1/day is charged !!!"; - } - } - } - } - f3.write((char *)&P,sizeof(Person)); + Person P; + Book B; + char cn[10], bn[10]; + int found = 0, flag = 0; + ifstream f1, f2; + ofstream f3; + cout << "\n !!!!! Book Issue !!!!! "; + cout << "\n Enter Person's Card no..."; + cin >> cn; + cout << "\n Enter Book Reference no.."; + cin >> bn; + f1.open("Person", ios::in | ios::binary); + f2.open("Book", ios::in | ios::binary); + f3.open("temp", ios::out | ios::binary); + while (f1.read((char *)&P, sizeof(Person)) && found == 0) + { + if (strcmp(P.cardno, cn) == 0) + { + found = 1; + if (P.noofbook == 0) + { + while (f2.read((char *)&B, sizeof(Book)) && flag == 0) + { + if (strcmp(B.refno, bn) == 0) + { + P.noofbook++; + flag = 1; + cout << "\n Book issued Succesfully !!!"; + cout << "\n Write Current Date in backside of book and submit within 20 days."; + cout << "\n Otherwise fine of Rs.1/day is charged !!!"; + } + } + } + } + f3.write((char *)&P, sizeof(Person)); } - f1.close(); - f2.close(); - f3.close(); - - remove("Person"); - rename("temp","Person"); - if(flag==0) - cout<<"\n Book Reference number does not exist !!!"; - if(found==0) - cout<<"\n Person Record Not Exist.."; + f1.close(); + f2.close(); + f3.close(); + + remove("Person"); + rename("temp", "Person"); + if (flag == 0) + cout << "\n Book Reference number does not exist !!!"; + if (found == 0) + cout << "\n Person Record Not Exist.."; } /* FUNCTION TO RETURN THE BOOK */ void Deposit() { -Person P; -Book B; -char cn[10],bn[10]; -int found=0,flag=0,day,fine; -ifstream f1,f2; -ofstream f3; -cout<<"\n !!! BOOK DEPOSIT !!! "; -cout<<"\n Enter Person's Card No..."; -cin>>cn; -cout<<"\n Enter Book Reference No..."; -cin>>bn; -f1.open("Person",ios::in|ios::binary); -f2.open("Book",ios::in|ios::binary); -f3.open("temp",ios::out|ios::binary); -while(f1.read((char*)&P,sizeof(Person))) -{ - if(strcmpi(P.cardno,cn)==0) - { - found=1; - if(P.noofbook!=0) - { - while(f2.read((char*)&B,sizeof(Book))&&flag==0) - { - if(strcmpi(B.refno,bn)==0) - { - P.noofbook--; - flag=1; - cout<<"\n Book Deposited in no of Days"; - cin>>day; - if(day>20) - { - fine=(day-20)*1; - cout<<"\n Fine has to deposited Rs."<> cn; + cout << "\n Enter Book Reference No..."; + cin >> bn; + f1.open("Person", ios::in | ios::binary); + f2.open("Book", ios::in | ios::binary); + f3.open("temp", ios::out | ios::binary); + while (f1.read((char *)&P, sizeof(Person))) + { + if (strcmp(P.cardno, cn) == 0) + { + found = 1; + if (P.noofbook != 0) + { + while (f2.read((char *)&B, sizeof(Book)) && flag == 0) + { + if (strcmp(B.refno, bn) == 0) + { + P.noofbook--; + flag = 1; + cout << "\n Book Deposited in no of Days"; + cin >> day; + if (day > 20) + { + fine = (day - 20) * 1; + cout << "\n Fine has to deposited Rs." << fine; + } + } + } + } + } + f3.write((char *)&P, sizeof(Person)); + } + f1.close(); + f2.close(); + f3.close(); + remove("Person"); + rename("temp", "Person"); + if (flag == 0) + cout << "\n Book Reference no does not exist!!!"; + else + cout << "\n Book is deposited...!!!"; + if (found == 0) + cout << "\n Person Record Not Exist.."; } - /* MENU */ void Menu() { -int choice; -char ch; -do -{ -clrscr(); -cout<<"\n !!!!!!!!!!! PUBLIC LIBRARY MANAGEMENT SYSTEM !!!!!!!!!!! \n"; -cout<<"\n********** Select the operation you would like to perform ********** "; -cout<<"\n"; -cout<<"\n 1.Add a Book Record "; -cout<<"\n 2.Add Person Details"; -cout<<"\n 3.Display all Records"; -cout<<"\n 4.Modify a Book Record "; -cout<<"\n 5.Modify a Person Record "; -cout<<"\n 6.Delete a Book Record "; -cout<<"\n 7.Delete a Person Record "; -cout<<"\n 8.Issue a Book "; -cout<<"\n 9.Return a Book"; -cout<<"\n 0.Exit "; -cout<<"\n Enter your choice(1-0)... "; -cin>>choice; -switch(choice) -{ -case 1: - AddRecord(); - break; -case 2: - AddPerson(); - break; -case 3: - DisplayBook(); - cout<<"\n"; - DisplayPerson(); - break; -case 4: - ModifyBook(); - break; -case 5: - ModifyPerson(); - break; -case 6: - DeleteBook(); - break; -case 7: - DeletePerson(); - break; -case 8: - Issue(); - break; -case 9: - Deposit(); - break; -case 0: - cout<<"\n!!!!!!!!!!!!!!! THANK YOU !!!!!!!!!!!!!!!"; - cout<<"\n ------- HAVE A NICE DAY ------- "; - cout<<"\n PUBLIC LIBRARY "; - break; -default: - cout<<"\n Wrong Choice.."; - break; -} -cout<<"\n Do you wish to work again?(y/n)"; -cin>>ch; + int choice; + char ch; + do + { + //clrscr(); + cout << "\n !!!!!!!!!!! PUBLIC LIBRARY MANAGEMENT SYSTEM !!!!!!!!!!! \n"; + cout << "\n********** Select the operation you would like to perform ********** "; + cout << "\n"; + cout << "\n 1.Add a Book Record "; + cout << "\n 2.Add Person Details"; + cout << "\n 3.Display all Records"; + cout << "\n 4.Modify a Book Record "; + cout << "\n 5.Modify a Person Record "; + cout << "\n 6.Delete a Book Record "; + cout << "\n 7.Delete a Person Record "; + cout << "\n 8.Issue a Book "; + cout << "\n 9.Return a Book"; + cout << "\n 0.Exit "; + cout << "\n Enter your choice(1-0)... "; + cin >> choice; + switch (choice) + { + case 1: + AddRecord(); + break; + case 2: + AddPerson(); + break; + case 3: + DisplayBook(); + cout << "\n"; + DisplayPerson(); + break; + case 4: + ModifyBook(); + break; + case 5: + ModifyPerson(); + break; + case 6: + DeleteBook(); + break; + case 7: + DeletePerson(); + break; + case 8: + Issue(); + break; + case 9: + Deposit(); + break; + case 0: + cout << "\n!!!!!!!!!!!!!!! THANK YOU !!!!!!!!!!!!!!!"; + cout << "\n ------- HAVE A NICE DAY ------- "; + cout << "\n PUBLIC LIBRARY "; + break; + default: + cout << "\n Wrong Choice.."; + break; + } + cout << "\n Do you wish to work again?(y/n)"; + cin >> ch; + } while (ch == 'y' || ch == 'Y'); } -while(ch=='y'||ch=='Y'); -} - /* MAIN FUNCTION */ -void main() -{ -clrscr(); -ofstream f("Book"); -int ch; -char c; -do -{ -clrscr(); -cout<<"\n !!!!!!!!!!!!!!!!!!!! WELCOME TO PUBLIC LIBRARY !!!!!!!!!!!!!!!!!!!! \n "; -cout<<"---------------------------------------------------------------------"; -cout<<"\n .......Select the operation you would like to perform....... \n "; -cout<<"\n 1.Open Book"; -cout<<"\n 2.Open Menu"; -cout<<"\n 3.Exit "; -cout<<"\n Enter your choice(1-3).. "; -cin>>ch; -switch(ch) -{ -case 1: - cout<<"\n !!!!! Book Record is opened !!!!!"; - DisplayBook(); - break; -case 2: - cout<<"\n-------------------- Menu is opened -------------------- \n"; - Menu(); - break; -case 3: - cout<<"\n --- Thanks for Visiting --- "; - cout<<"\n..... Have a nice day....."; - break; -default: - cout<<"\n wrong choice!!"; - break; -} -cout<<"\n Do you wish to work again?(y/n)"; -cin>>c; -} -while(c=='y'||c=='Y'); -getch(); +int main() +{ + //clrscr(); + ofstream f("Book"); + int ch; + char c; + do + { + //clrscr(); + cout << "\n !!!!!!!!!!!!!!!!!!!! WELCOME TO PUBLIC LIBRARY !!!!!!!!!!!!!!!!!!!! \n "; + cout << "---------------------------------------------------------------------"; + cout << "\n .......Select the operation you would like to perform....... \n "; + cout << "\n 1.Open Book"; + cout << "\n 2.Open Menu"; + cout << "\n 3.Exit "; + cout << "\n Enter your choice(1-3).. "; + cin >> ch; + switch (ch) + { + case 1: + cout << "\n !!!!! Book Record is opened !!!!!"; + DisplayBook(); + break; + case 2: + cout << "\n-------------------- Menu is opened -------------------- \n"; + Menu(); + break; + case 3: + cout << "\n --- Thanks for Visiting --- "; + cout << "\n..... Have a nice day....."; + break; + default: + cout << "\n wrong choice!!"; + break; + } + cout << "\n Do you wish to work again?(y/n)"; + cin >> c; + } while (c == 'y' || c == 'Y'); + //getch(); } -/* END */ \ No newline at end of file +/* END */