SlideShare a Scribd company logo
#include<fstream>
#include<cstring>
#include<iomanip>
#include<iostream>
using namespace std;
class book
{
char bno[6];
char bname[50];
char aname[20];
public:
void create_book()
{
cout<<"nNEW BOOK ENTRY...n";
cout<<"nEnter The book no.";
cin>>bno;
cout<<"nnEnter The Name of The Book ";
cin>>bname;
cout<<"nnEnter The Author's Name ";
cin>>aname;
cout<<"nnnBook Created..";
}
void show_book()
{
cout<<"nBook no. : "<<bno;
cout<<"nBook Name : ";
puts(bname);
cout<<"Author Name : ";
puts(aname);
}
void modify_book()
{
cout<<"nBook no. : "<<bno;
cout<<"nModify Book Name : ";
cin>>bname;
cout<<"nModify Author's Name of Book : ";
cin>>aname;
}
char* retbno()
{
return bno;
}
void report()
{cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;}
};
class student
{
char admno[6];
char name[20];
char stbno[6];
int token;
public:
void create_student()
{
cout<<"nNEW STUDENT ENTRY...n";
cout<<"nEnter The admission no. ";
cin>>admno;
cout<<"nnEnter The Name of The Student ";
cin>>name;
token=0;
stbno[0]='0';
cout<<"nnStudent Record Created..";
}
void show_student()
{
cout<<"ntAdmission no. : "<<admno;
cout<<"ntStudent Name : ";
puts(name);
cout<<"ntNo of Book issued : "<<token;
if(token==1)
cout<<"ntBook No "<<stbno;
}
void modify_student()
{
cout<<"nAdmission no. : "<<admno;
cout<<"nModify Student Name : ";
cin>>name;
}
char* retadmno()
{
return admno;
}
char* retstbno()
{
return stbno;
}
int rettoken()
{
return token;
}
void addtoken()
{token=1;}
void resettoken()
{token=0;}
void getstbno(char t[])
{
strcpy(stbno,t);
}
void report()
{cout<<"t"<<admno<<setw(20)<<name<<setw(10)<<token<<endl;}
};
fstream fp,fp1;
book bk;
student st;
void write_book()
{
char ch;
fp.open("book.dat",ios::out|ios::app);
do
{
bk.create_book();
fp.write((char*)&bk,sizeof(book));
cout<<"nntDo you want to add more record..(y/n?)";
cin>>ch;
}while(ch=='y'||ch=='Y');
fp.close();
}
void write_student()
{
char ch;
fp.open("student.dat",ios::out|ios::app);
do
{
st.create_student();
fp.write((char*)&st,sizeof(student));
cout<<"nntDo you want to add more record..(y/n?)";
cin>>ch;
}while(ch=='y'||ch=='Y');
fp.close();
}
void display_spb(char n[])
{
cout<<"ntBOOK DETAILSn";
int flag=0;
fp.open("book.dat",ios::in);
while(fp.read((char*)&bk,sizeof(book)))
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_book();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"nntBook does not exist";
return;
}
void display_sps(char n[])
{
cout<<"ntSTUDENT DETAILSn";
int flag=0;
fp.open("student.dat",ios::in);
while(fp.read((char*)&st,sizeof(student)))
{
if((strcmpi(st.retadmno(),n)==0))
{
st.show_student();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"nnStudent does not exist";
return;
}
void modify_book()
{
char n[6];
int found=0;
cout<<"nntMODIFY BOOK RECORD.... ";
cout<<"nntEnter The book no. of The book";
cin>>n;
fp.open("book.dat",ios::in|ios::out);
while(fp.read((char*)&bk,sizeof(book)) && found==0)
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_book();
cout<<"nEnter The New Details of book"<<endl;
bk.modify_book();
int pos=-1*sizeof(bk);
fp.seekp(pos,ios::cur);
fp.write((char*)&bk,sizeof(book));
cout<<"nnt Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"nn Record Not Found ";
return;
}
void modify_student()
{
char n[6];
int found=0;
cout<<"nntMODIFY STUDENT RECORD... ";
cout<<"nntEnter The admission no. of The student";
cin>>n;
fp.open("student.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),n)==0)
{
st.show_student();
cout<<"nEnter The New Details of student"<<endl;
st.modify_student();
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<"nnt Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"nn Record Not Found ";
return;
}
void delete_student()
{
char n[6];
int flag=0;
cout<<"nnntDELETE STUDENT...";
cout<<"nnEnter The admission no. of the Student You Want To Delete : ";
cin>>n;
fp.open("student.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&st,sizeof(student)))
{
if(strcmpi(st.retadmno(),n)!=0)
fp2.write((char*)&st,sizeof(student));
else
flag=1;
}
fp2.close();
fp.close();
remove("student.dat");
rename("Temp.dat","student.dat");
if(flag==1)
cout<<"nntRecord Deleted ..";
else
cout<<"nntRecord not found";
return;
}
void delete_book()
{
char n[6];
cout<<"nnntDELETE BOOK ...";
cout<<"nntEnter The Book no. of the Book You Want To Delete : ";
cin>>n;
fp.open("book.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&bk,sizeof(book)))
{
if(strcmpi(bk.retbno(),n)!=0)
{
fp2.write((char*)&bk,sizeof(book));
}
}
fp2.close();
fp.close();
remove("book.dat");
rename("Temp.dat","book.dat");
cout<<"nntRecord Deleted ..";
return;
}
void display_alls()
{
fp.open("student.dat",ios::in);
if(!fp)
{
cout<<"tERROR!!! FILE COULD NOT BE OPEN ";
return;
}
cout<<"nnttSTUDENT LISTnn";
cout<<"==================================================================n";
cout<<"tAdmission No."<<setw(10)<<"Name"<<setw(20)<<"Book Issuedn";
cout<<"==================================================================n";
while(fp.read((char*)&st,sizeof(student)))
st.report();
fp.close();
return;
}
void display_allb()
{
fp.open("book.dat",ios::in);
if(fp==0)
{
cout<<"tERROR!!! FILE COULD NOT BE OPEN ";
return;
}
cout<<"nnttBook LISTnn";
cout<<"=========================================================================
n";
cout<<"tBook Number"<<setw(20)<<"Book Name"<<setw(25)<<"Authorn";
cout<<"=========================================================================
n";
while(fp.read((char*)&bk,sizeof(book)))
bk.report();
fp.close();
return;
}
void book_issue()
{
char sn[6],bn[6];
int found=0,flag=0;
cout<<"nntBOOK ISSUE ...";
cout<<"nntEnter The student's admission no.";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
fp1.open("book.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(!strcmpi(st.retadmno(),sn))
{
found=1;
if(!st.rettoken())
{
cout<<"nntEnter the book no. ";
cin>>bn;
while(fp1.read((char*)&bk,sizeof(book))&& !flag)
{
if(!strcmpi(bk.retbno(),bn))
{
bk.show_book();
flag=1;
st.addtoken();
st.getstbno(bk.retbno());
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<"nnt Book issued
successfullynnPlease Note: Write the current date in backside of your book and
submit it within 15 days. Fine Rs. 1 for each day after 15 days period";
}
}
if(flag==0)
cout<<"tBook no does not exist";
}
else
cout<<"t!!!!You have not returned the last book!!!! ";
}
}
if(found==0)
cout<<"tStudent record not exist...";
return;
fp.close();
fp1.close();
}
void book_deposit()
{
char sn[6],bn[6];
int found=0,flag=0,day,fine;
cout<<"nntBOOK DEPOSIT ...";
cout<<"nntEnter The student’s admission no.";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
fp1.open("book.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && !found)
{
if(!strcmpi(st.retadmno(),sn))
{
found=1;
if(st.rettoken()==1)
{
while(fp1.read((char*)&bk,sizeof(book))&& !flag)
{
if(strcmpi(bk.retbno(),st.retstbno())==0)
{
bk.show_book();
flag=1;
cout<<"nnBook deposited in no. of days";
cin>>day;
if(day>15)
{
fine=(day-15)*1;
cout<<"nnFine has to deposited Rs.
"<<fine;
}
st.resettoken();
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<"nnt Book deposited successfully";
}
}
if(!flag)
cout<<"tBook no does not exist";
}
else
cout<<"tNo book is issued..please check!!";
}
}
if(!found)
cout<<"tStudent record not exist...";
return;
fp.close();
fp1.close();
}
void intro(){
for(int i=0;i<192;i++){
cout<<"*";
}
cout<<"tMADE BY:- tttROLL NO:-n";
cout<<"tHIMANSHU GARGttt1130272n";
cout<<"tNAMAN MAHESHWARI tt1130275n";
cout<<"tBHUWAN ABROLttt1130281n";
for(int i=0;i<192;i++){
cout<<"*";
}
cout<<"nttttttPRESENTS";
cout<<"nnttt t*******************************n";
cout<<"ttttt** LIBRARY MANAGEMENT SYSTEM **";
cout<<"nttt t*******************************n";
for(int i=0;i<192;i++){
cout<<"*";
}
return;
}
void admin_menu()
{
int ch2;
cout<<"nnntADMINISTRATOR MENU";
cout<<"nnt1.CREATE STUDENT RECORD";
cout<<"nnt2.DISPLAY ALL STUDENTS RECORD";
cout<<"nnt3.DISPLAY SPECIFIC STUDENT RECORD ";
cout<<"nnt4.MODIFY STUDENT RECORD";
cout<<"nnt5.DELETE STUDENT RECORD";
cout<<"nnt6.CREATE BOOK ";
cout<<"nnt7.DISPLAY ALL BOOKS ";
cout<<"nnt8.DISPLAY SPECIFIC BOOK ";
cout<<"nnt9.MODIFY BOOK ";
cout<<"nnt10.DELETE BOOK ";
cout<<"nnt11.BACK TO MAIN MENU";
cout<<"nntPlease Enter Your Choice (1-11) ";
cin>>ch2;
switch(ch2)
{
case 1: write_student();
break;
case 2: display_alls();
break;
case 3: char num[6];
cout<<"nntPlease Enter The Admission No. ";
cin>>num;
display_sps(num);
break;
case 4: modify_student();
break;
case 5: delete_student();
break;
case 6: write_book();
break;
case 7: display_allb();
break;
case 8: {
char num[6];
cout<<"nntPlease Enter The book No. ";
cin>>num;
display_spb(num);
break;
}
case 9: modify_book();
break;
case 10: delete_book();
break;
case 11: return;
default:cout<<"a";
}
admin_menu();
}
int main()
{
char ch;
intro();
do{
cout<<"nnntMAIN MENU";
cout<<"nnt01. BOOK ISSUE";
cout<<"nnt02. BOOK DEPOSIT";
cout<<"nnt03. ADMINISTRATOR MENU";
cout<<"nnt04. EXIT";
cout<<"nntPlease Select Your Option (1-4) ";
cin>>ch;
switch(ch)
{
case '1': book_issue();
break;
case '2': book_deposit();
break;
case '3': admin_menu();
break;
case '4': exit(0);
default :cout<<"a";
}
}while(ch!='4');
return 0;
}
break;
case 7: display_allb();
break;
case 8: {
char num[6];
cout<<"nntPlease Enter The book No. ";
cin>>num;
display_spb(num);
break;
}
case 9: modify_book();
break;
case 10: delete_book();
break;
case 11: return;
default:cout<<"a";
}
admin_menu();
}
int main()
{
char ch;
intro();
do{
cout<<"nnntMAIN MENU";
cout<<"nnt01. BOOK ISSUE";
cout<<"nnt02. BOOK DEPOSIT";
cout<<"nnt03. ADMINISTRATOR MENU";
cout<<"nnt04. EXIT";
cout<<"nntPlease Select Your Option (1-4) ";
cin>>ch;
switch(ch)
{
case '1': book_issue();
break;
case '2': book_deposit();
break;
case '3': admin_menu();
break;
case '4': exit(0);
default :cout<<"a";
}
}while(ch!='4');
return 0;
}

More Related Content

What's hot

20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
Tatsuhiko Miyagawa
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
Remy Sharp
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
brian d foy
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
brian d foy
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
Ian Barber
 
Bodlogiin code
Bodlogiin codeBodlogiin code
Bodlogiin code
orgil
 
Rebooting TEI Pointers
Rebooting TEI PointersRebooting TEI Pointers
Rebooting TEI Pointers
Hugh Cayless
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
Augusto Pascutti
 
ZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 VersionZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 Version
Ian Barber
 
SfCon: Test Driven Development
SfCon: Test Driven DevelopmentSfCon: Test Driven Development
SfCon: Test Driven Development
Augusto Pascutti
 
How DRY impacts JavaScript performance // Faster JavaScript execution for the...
How DRY impacts JavaScript performance // Faster JavaScript execution for the...How DRY impacts JavaScript performance // Faster JavaScript execution for the...
How DRY impacts JavaScript performance // Faster JavaScript execution for the...
Mathias Bynens
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
brian d foy
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heureCréer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heure
Amaury Bouchard
 
Tgh.pl
Tgh.plTgh.pl
Tgh.pl
iskabom
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
MongoDB
 

What's hot (16)

20 modules i haven't yet talked about
20 modules i haven't yet talked about20 modules i haven't yet talked about
20 modules i haven't yet talked about
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
Perl Bag of Tricks - Baltimore Perl mongers
Perl Bag of Tricks  -  Baltimore Perl mongersPerl Bag of Tricks  -  Baltimore Perl mongers
Perl Bag of Tricks - Baltimore Perl mongers
 
ZeroMQ Is The Answer
ZeroMQ Is The AnswerZeroMQ Is The Answer
ZeroMQ Is The Answer
 
Bodlogiin code
Bodlogiin codeBodlogiin code
Bodlogiin code
 
Rebooting TEI Pointers
Rebooting TEI PointersRebooting TEI Pointers
Rebooting TEI Pointers
 
Melhorando sua API com DSLs
Melhorando sua API com DSLsMelhorando sua API com DSLs
Melhorando sua API com DSLs
 
ZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 VersionZeroMQ Is The Answer: PHP Tek 11 Version
ZeroMQ Is The Answer: PHP Tek 11 Version
 
SfCon: Test Driven Development
SfCon: Test Driven DevelopmentSfCon: Test Driven Development
SfCon: Test Driven Development
 
How DRY impacts JavaScript performance // Faster JavaScript execution for the...
How DRY impacts JavaScript performance // Faster JavaScript execution for the...How DRY impacts JavaScript performance // Faster JavaScript execution for the...
How DRY impacts JavaScript performance // Faster JavaScript execution for the...
 
The Magic Of Tie
The Magic Of TieThe Magic Of Tie
The Magic Of Tie
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Créer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heureCréer une base NoSQL en 1 heure
Créer une base NoSQL en 1 heure
 
Tgh.pl
Tgh.plTgh.pl
Tgh.pl
 
Building Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at StripeBuilding Real Time Systems on MongoDB Using the Oplog at Stripe
Building Real Time Systems on MongoDB Using the Oplog at Stripe
 

Similar to Library management system code

Sumit pandit
Sumit panditSumit pandit
Sumit pandit
coolpandit
 
#include stdafx.h#include iostream#include Stringusing.pdf
#include stdafx.h#include iostream#include Stringusing.pdf#include stdafx.h#include iostream#include Stringusing.pdf
#include stdafx.h#include iostream#include Stringusing.pdf
anokhilalmobile
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
Swakriti Rathore
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
Jeremy Kendall
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
Olaf Alders
 
Bangun datar dan bangun ruang
Bangun datar dan bangun ruangBangun datar dan bangun ruang
Bangun datar dan bangun ruang
SanSan Yagyoo
 
Cbse project computer science xii 2018
Cbse project computer science xii 2018Cbse project computer science xii 2018
Cbse project computer science xii 2018
Kaushalesh Upadhyay
 
C project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer recordC project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer record
Zaibi Gondal
 
Ip lab
Ip labIp lab
Ip lab
Ema Dunphy
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
leo lapworth
 
Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11
Goro Fuji
 
DBIx::Class beginners
DBIx::Class beginnersDBIx::Class beginners
DBIx::Class beginners
leo lapworth
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
Yasuharu Nakano
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12
Raunak Yadav
 
Bookstore-Project
Bookstore-ProjectBookstore-Project
Bookstore-Project
Christopher Singleton
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
Hugo Hamon
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
Javier Arturo Rodríguez
 
A piece of sugar in your client-side development
A piece of sugar in your client-side developmentA piece of sugar in your client-side development
A piece of sugar in your client-side development
Nicolas Blanco
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
Kevin Hazzard
 

Similar to Library management system code (20)

Sumit pandit
Sumit panditSumit pandit
Sumit pandit
 
#include stdafx.h#include iostream#include Stringusing.pdf
#include stdafx.h#include iostream#include Stringusing.pdf#include stdafx.h#include iostream#include Stringusing.pdf
#include stdafx.h#include iostream#include Stringusing.pdf
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Php 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the GoodPhp 102: Out with the Bad, In with the Good
Php 102: Out with the Bad, In with the Good
 
(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit(Ab)Using the MetaCPAN API for Fun and Profit
(Ab)Using the MetaCPAN API for Fun and Profit
 
Bangun datar dan bangun ruang
Bangun datar dan bangun ruangBangun datar dan bangun ruang
Bangun datar dan bangun ruang
 
Cbse project computer science xii 2018
Cbse project computer science xii 2018Cbse project computer science xii 2018
Cbse project computer science xii 2018
 
C project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer recordC project on a bookshop for saving of coustmer record
C project on a bookshop for saving of coustmer record
 
Ip lab
Ip labIp lab
Ip lab
 
DBIx::Class introduction - 2010
DBIx::Class introduction - 2010DBIx::Class introduction - 2010
DBIx::Class introduction - 2010
 
Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11Xslate sv perl-2013-7-11
Xslate sv perl-2013-7-11
 
DBIx::Class beginners
DBIx::Class beginnersDBIx::Class beginners
DBIx::Class beginners
 
JavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovyJavaSE7 Launch Event: Java7xGroovy
JavaSE7 Launch Event: Java7xGroovy
 
Computer Science investigatory project class 12
Computer Science investigatory project class 12Computer Science investigatory project class 12
Computer Science investigatory project class 12
 
Bookstore-Project
Bookstore-ProjectBookstore-Project
Bookstore-Project
 
The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01Barcelona.pm Curs1211 sess01
Barcelona.pm Curs1211 sess01
 
A piece of sugar in your client-side development
A piece of sugar in your client-side developmentA piece of sugar in your client-side development
A piece of sugar in your client-side development
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607C# 6 and 7 and Futures 20180607
C# 6 and 7 and Futures 20180607
 

Recently uploaded

一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
Hitesh Mohapatra
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
ZainabHashmi17
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
skuxot
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
gestioneergodomus
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 

Recently uploaded (20)

一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
Generative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of contentGenerative AI leverages algorithms to create various forms of content
Generative AI leverages algorithms to create various forms of content
 
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
This is my Environmental physics presentation
This is my Environmental physics presentationThis is my Environmental physics presentation
This is my Environmental physics presentation
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
DfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributionsDfMAy 2024 - key insights and contributions
DfMAy 2024 - key insights and contributions
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 

Library management system code

  • 1. #include<fstream> #include<cstring> #include<iomanip> #include<iostream> using namespace std; class book { char bno[6]; char bname[50]; char aname[20]; public: void create_book() { cout<<"nNEW BOOK ENTRY...n"; cout<<"nEnter The book no."; cin>>bno; cout<<"nnEnter The Name of The Book "; cin>>bname; cout<<"nnEnter The Author's Name "; cin>>aname; cout<<"nnnBook Created.."; } void show_book() { cout<<"nBook no. : "<<bno; cout<<"nBook Name : "; puts(bname); cout<<"Author Name : "; puts(aname); } void modify_book() { cout<<"nBook no. : "<<bno; cout<<"nModify Book Name : "; cin>>bname; cout<<"nModify Author's Name of Book : "; cin>>aname; } char* retbno() { return bno; } void report() {cout<<bno<<setw(30)<<bname<<setw(30)<<aname<<endl;} }; class student { char admno[6]; char name[20]; char stbno[6]; int token; public: void create_student() { cout<<"nNEW STUDENT ENTRY...n"; cout<<"nEnter The admission no. "; cin>>admno;
  • 2. cout<<"nnEnter The Name of The Student "; cin>>name; token=0; stbno[0]='0'; cout<<"nnStudent Record Created.."; } void show_student() { cout<<"ntAdmission no. : "<<admno; cout<<"ntStudent Name : "; puts(name); cout<<"ntNo of Book issued : "<<token; if(token==1) cout<<"ntBook No "<<stbno; } void modify_student() { cout<<"nAdmission no. : "<<admno; cout<<"nModify Student Name : "; cin>>name; } char* retadmno() { return admno; } char* retstbno() { return stbno; } int rettoken() { return token; } void addtoken() {token=1;} void resettoken() {token=0;} void getstbno(char t[]) { strcpy(stbno,t); } void report() {cout<<"t"<<admno<<setw(20)<<name<<setw(10)<<token<<endl;} }; fstream fp,fp1; book bk; student st; void write_book() { char ch; fp.open("book.dat",ios::out|ios::app); do
  • 3. { bk.create_book(); fp.write((char*)&bk,sizeof(book)); cout<<"nntDo you want to add more record..(y/n?)"; cin>>ch; }while(ch=='y'||ch=='Y'); fp.close(); } void write_student() { char ch; fp.open("student.dat",ios::out|ios::app); do { st.create_student(); fp.write((char*)&st,sizeof(student)); cout<<"nntDo you want to add more record..(y/n?)"; cin>>ch; }while(ch=='y'||ch=='Y'); fp.close(); } void display_spb(char n[]) { cout<<"ntBOOK DETAILSn"; int flag=0; fp.open("book.dat",ios::in); while(fp.read((char*)&bk,sizeof(book))) { if(strcmpi(bk.retbno(),n)==0) { bk.show_book(); flag=1; } } fp.close(); if(flag==0) cout<<"nntBook does not exist"; return; } void display_sps(char n[]) { cout<<"ntSTUDENT DETAILSn"; int flag=0; fp.open("student.dat",ios::in); while(fp.read((char*)&st,sizeof(student))) { if((strcmpi(st.retadmno(),n)==0)) { st.show_student(); flag=1; } } fp.close(); if(flag==0) cout<<"nnStudent does not exist"; return; }
  • 4. void modify_book() { char n[6]; int found=0; cout<<"nntMODIFY BOOK RECORD.... "; cout<<"nntEnter The book no. of The book"; cin>>n; fp.open("book.dat",ios::in|ios::out); while(fp.read((char*)&bk,sizeof(book)) && found==0) { if(strcmpi(bk.retbno(),n)==0) { bk.show_book(); cout<<"nEnter The New Details of book"<<endl; bk.modify_book(); int pos=-1*sizeof(bk); fp.seekp(pos,ios::cur); fp.write((char*)&bk,sizeof(book)); cout<<"nnt Record Updated"; found=1; } } fp.close(); if(found==0) cout<<"nn Record Not Found "; return; } void modify_student() { char n[6]; int found=0; cout<<"nntMODIFY STUDENT RECORD... "; cout<<"nntEnter The admission no. of The student"; cin>>n; fp.open("student.dat",ios::in|ios::out); while(fp.read((char*)&st,sizeof(student)) && found==0) { if(strcmpi(st.retadmno(),n)==0) { st.show_student(); cout<<"nEnter The New Details of student"<<endl; st.modify_student(); int pos=-1*sizeof(st); fp.seekp(pos,ios::cur); fp.write((char*)&st,sizeof(student)); cout<<"nnt Record Updated"; found=1; } } fp.close(); if(found==0) cout<<"nn Record Not Found "; return; } void delete_student() { char n[6]; int flag=0;
  • 5. cout<<"nnntDELETE STUDENT..."; cout<<"nnEnter The admission no. of the Student You Want To Delete : "; cin>>n; fp.open("student.dat",ios::in|ios::out); fstream fp2; fp2.open("Temp.dat",ios::out); fp.seekg(0,ios::beg); while(fp.read((char*)&st,sizeof(student))) { if(strcmpi(st.retadmno(),n)!=0) fp2.write((char*)&st,sizeof(student)); else flag=1; } fp2.close(); fp.close(); remove("student.dat"); rename("Temp.dat","student.dat"); if(flag==1) cout<<"nntRecord Deleted .."; else cout<<"nntRecord not found"; return; } void delete_book() { char n[6]; cout<<"nnntDELETE BOOK ..."; cout<<"nntEnter The Book no. of the Book You Want To Delete : "; cin>>n; fp.open("book.dat",ios::in|ios::out); fstream fp2; fp2.open("Temp.dat",ios::out); fp.seekg(0,ios::beg); while(fp.read((char*)&bk,sizeof(book))) { if(strcmpi(bk.retbno(),n)!=0) { fp2.write((char*)&bk,sizeof(book)); } } fp2.close(); fp.close(); remove("book.dat"); rename("Temp.dat","book.dat"); cout<<"nntRecord Deleted .."; return; } void display_alls() { fp.open("student.dat",ios::in); if(!fp) { cout<<"tERROR!!! FILE COULD NOT BE OPEN "; return; } cout<<"nnttSTUDENT LISTnn";
  • 6. cout<<"==================================================================n"; cout<<"tAdmission No."<<setw(10)<<"Name"<<setw(20)<<"Book Issuedn"; cout<<"==================================================================n"; while(fp.read((char*)&st,sizeof(student))) st.report(); fp.close(); return; } void display_allb() { fp.open("book.dat",ios::in); if(fp==0) { cout<<"tERROR!!! FILE COULD NOT BE OPEN "; return; } cout<<"nnttBook LISTnn"; cout<<"========================================================================= n"; cout<<"tBook Number"<<setw(20)<<"Book Name"<<setw(25)<<"Authorn"; cout<<"========================================================================= n"; while(fp.read((char*)&bk,sizeof(book))) bk.report(); fp.close(); return; } void book_issue() { char sn[6],bn[6]; int found=0,flag=0; cout<<"nntBOOK ISSUE ..."; cout<<"nntEnter The student's admission no."; cin>>sn; fp.open("student.dat",ios::in|ios::out); fp1.open("book.dat",ios::in|ios::out); while(fp.read((char*)&st,sizeof(student)) && found==0) { if(!strcmpi(st.retadmno(),sn)) { found=1; if(!st.rettoken()) { cout<<"nntEnter the book no. "; cin>>bn; while(fp1.read((char*)&bk,sizeof(book))&& !flag) { if(!strcmpi(bk.retbno(),bn)) { bk.show_book(); flag=1; st.addtoken(); st.getstbno(bk.retbno());
  • 7. int pos=-1*sizeof(st); fp.seekp(pos,ios::cur); fp.write((char*)&st,sizeof(student)); cout<<"nnt Book issued successfullynnPlease Note: Write the current date in backside of your book and submit it within 15 days. Fine Rs. 1 for each day after 15 days period"; } } if(flag==0) cout<<"tBook no does not exist"; } else cout<<"t!!!!You have not returned the last book!!!! "; } } if(found==0) cout<<"tStudent record not exist..."; return; fp.close(); fp1.close(); } void book_deposit() { char sn[6],bn[6]; int found=0,flag=0,day,fine; cout<<"nntBOOK DEPOSIT ..."; cout<<"nntEnter The student’s admission no."; cin>>sn; fp.open("student.dat",ios::in|ios::out); fp1.open("book.dat",ios::in|ios::out); while(fp.read((char*)&st,sizeof(student)) && !found) { if(!strcmpi(st.retadmno(),sn)) { found=1; if(st.rettoken()==1) { while(fp1.read((char*)&bk,sizeof(book))&& !flag) { if(strcmpi(bk.retbno(),st.retstbno())==0) { bk.show_book(); flag=1; cout<<"nnBook deposited in no. of days"; cin>>day; if(day>15) { fine=(day-15)*1; cout<<"nnFine has to deposited Rs. "<<fine; } st.resettoken(); int pos=-1*sizeof(st); fp.seekp(pos,ios::cur); fp.write((char*)&st,sizeof(student)); cout<<"nnt Book deposited successfully"; } } if(!flag) cout<<"tBook no does not exist"; } else
  • 8. cout<<"tNo book is issued..please check!!"; } } if(!found) cout<<"tStudent record not exist..."; return; fp.close(); fp1.close(); } void intro(){ for(int i=0;i<192;i++){ cout<<"*"; } cout<<"tMADE BY:- tttROLL NO:-n"; cout<<"tHIMANSHU GARGttt1130272n"; cout<<"tNAMAN MAHESHWARI tt1130275n"; cout<<"tBHUWAN ABROLttt1130281n"; for(int i=0;i<192;i++){ cout<<"*"; } cout<<"nttttttPRESENTS"; cout<<"nnttt t*******************************n"; cout<<"ttttt** LIBRARY MANAGEMENT SYSTEM **"; cout<<"nttt t*******************************n"; for(int i=0;i<192;i++){ cout<<"*"; } return; } void admin_menu() { int ch2; cout<<"nnntADMINISTRATOR MENU"; cout<<"nnt1.CREATE STUDENT RECORD"; cout<<"nnt2.DISPLAY ALL STUDENTS RECORD"; cout<<"nnt3.DISPLAY SPECIFIC STUDENT RECORD "; cout<<"nnt4.MODIFY STUDENT RECORD"; cout<<"nnt5.DELETE STUDENT RECORD"; cout<<"nnt6.CREATE BOOK "; cout<<"nnt7.DISPLAY ALL BOOKS "; cout<<"nnt8.DISPLAY SPECIFIC BOOK "; cout<<"nnt9.MODIFY BOOK "; cout<<"nnt10.DELETE BOOK "; cout<<"nnt11.BACK TO MAIN MENU"; cout<<"nntPlease Enter Your Choice (1-11) "; cin>>ch2; switch(ch2) { case 1: write_student(); break; case 2: display_alls(); break; case 3: char num[6]; cout<<"nntPlease Enter The Admission No. "; cin>>num; display_sps(num); break; case 4: modify_student(); break; case 5: delete_student(); break; case 6: write_book();
  • 9. break; case 7: display_allb(); break; case 8: { char num[6]; cout<<"nntPlease Enter The book No. "; cin>>num; display_spb(num); break; } case 9: modify_book(); break; case 10: delete_book(); break; case 11: return; default:cout<<"a"; } admin_menu(); } int main() { char ch; intro(); do{ cout<<"nnntMAIN MENU"; cout<<"nnt01. BOOK ISSUE"; cout<<"nnt02. BOOK DEPOSIT"; cout<<"nnt03. ADMINISTRATOR MENU"; cout<<"nnt04. EXIT"; cout<<"nntPlease Select Your Option (1-4) "; cin>>ch; switch(ch) { case '1': book_issue(); break; case '2': book_deposit(); break; case '3': admin_menu(); break; case '4': exit(0); default :cout<<"a"; } }while(ch!='4'); return 0; }
  • 10. break; case 7: display_allb(); break; case 8: { char num[6]; cout<<"nntPlease Enter The book No. "; cin>>num; display_spb(num); break; } case 9: modify_book(); break; case 10: delete_book(); break; case 11: return; default:cout<<"a"; } admin_menu(); } int main() { char ch; intro(); do{ cout<<"nnntMAIN MENU"; cout<<"nnt01. BOOK ISSUE"; cout<<"nnt02. BOOK DEPOSIT"; cout<<"nnt03. ADMINISTRATOR MENU"; cout<<"nnt04. EXIT"; cout<<"nntPlease Select Your Option (1-4) "; cin>>ch; switch(ch) { case '1': book_issue(); break; case '2': book_deposit(); break; case '3': admin_menu(); break; case '4': exit(0); default :cout<<"a"; } }while(ch!='4'); return 0; }