can anyone help me to make a program which is library borrowing system it is only a borrowing system that will input the name of the student, Id number, name of book, and number of pages...
and it will use fstream to the name of the borrower and it will save it in txt file. and if it is possible i want to make an name of the books using txt file also....
struct book {
string bname;
string aname;
string bnumber;
};
char c;
int a,b,d;
char character;
int main ()
{
string x,user,id;
cout<< "\n\n\nWelcome to Library Books Management System\n\n\n";
cout<< "\n\n\nDo you want to borrow a book?\n\n\n";
start:
cout<< "\n\n\nNo or Yes\n\n\n";
cin>>x;
if (x=="Yes"||x=="yes"||x=="y"||x=="Y"||x=="YES")
{
goto mainmenu;
}
else
{
system ("pause");
cout<< "\n\n\nPlease refrain from loitering at the library\n\n\n";
system ("pause");
exit (0);
}
system ("pause");
system ("cls");
mainmenu:
system("cls");
cout<<"\n--------------------------------------------------------------------------------"<<endl;
gotoxy (31,2);cout<<"Library Book System"<<endl;
cout<<"--------------------------------------------------------------------------------"<<endl;
cout<<"\n[1] Borrow book\n[2] Quit";
cout<<"\n\nSelect Transaction: ";
cin>>d;
system ("cls");
switch (d) {
case 1: goto b;
b:
{
ofstream brrowd;
cout<<"\n--------"<<endl;
cout<<"BORROW BOOK";
cout<<"\n--------"<<endl;
sum=status[0]+status[1]+status[2]+status[3]+status[4]+status[5]+status[6]+status[7]+status[8]+status[9]+status[10]+status[11]+status[12]+status[13]+status[14]+status[15]+status[16]+status[17]+status[18]+status[19];
brrowd.open("brrowd.txt");
if (sum==20)
{
cout<<"All the books were borrowed"<<endl;
brrowd<<"All the books were borrowed"<<endl;
}
else ;
cout<<"What would you like to borrow?"<<endl;
brrowd<<"What would you like to borrow?"<<endl;
for (b=0;b<20;b++)
{
cout<<"Book "<<b+1<<" : ";
if (status[booknumber-1]==1)
{
system("cls");
cout<<"Someone has already borrowed that book. Please choose another book"<<endl;
system("pause");
system("cls");
goto b;
}
else if
(status[booknumber-1]==0){
cout<<"thank you for borrowing!!";
status[booknumber-1]=1;
cout<<"\nPlease enter your name\n";
cin>>user;
cout<<"\nPlease enter your ID number\n";
cin>>id;
}
cout<<"\n\nDo you want another transaction? (Y/N) ";
cin>>c;
if (c=='y' || c=='Y') {
system ("cls");
goto mainmenu; }
else if(c!='y'||c!='Y'||c!='n'||c!='N')
{
cout<<"pls..."<<endl<<"just answer yes or no..";
system("pause");
goto b;
}
else
exit (0);
}
}
This sounds like an assignment. Read the assignment sentence-by-sentence and and start writing declarations (not code) for classes and methods to do each part. Put some comments before the methods to indicate exactly what they're supposed to do.
When your done, go back and re-read the assignment, sentence by sentence. Check to ensure that what you want will do everything. You'll find that you made some mistakes the first time that must be corrected.
Keep doing this until you're confident that the classes and methods will do what you need.
Then just write the code for each method.
If you get stuck for more than an hour, post your work (and the assignment) and ask your question. Be as specific as possible.