#include<iostream>
#include <string>
#include <fstream>
using namespace std;
ofstream
outfile;
ifstream
infile;
int fine = 100;
string
user_name[50] ;
int lib_no;
string
author_name[50];
string
book_name[50];
int date_of_submission[50];
int date_of_publication[50];
int return_date[50];
//date to return book
int returned_date[50];
// date a person retuerned
class user
{
public:
int getdata()
{
system("CLS");
outfile.open("D:\myFile.txt",ios_base::app);
cout<<"\nEnter the library
number of user:\t";
cin>>lib_no;
outfile << endl;
outfile << lib_no << endl;
cout<<"\nEnter the name of
user:\t";
cin.ignore();
getline(cin,user_name[lib_no]);
outfile << user_name[lib_no] << endl;
return lib_no;
}
void putdata(int lib)
{
cout<<"The name of user
is:"<<user_name[lib]<<endl;
cout<<"The library number of
user is:"<<lib<<endl;
}
};
class book :public user
{
private:
public:
int getdata()
{
int lib = user::getdata();
cout<<"\n\n*\\Book Details
Are \\*";
cout<<endl;
cout<<"\nEnter the name of a
book:\t";
getline(cin,book_name[lib]);
outfile << book_name[lib] << endl;
cout<<"\nEnter the name of
author:\t";
getline(cin,author_name[lib]);
outfile << author_name[lib] << endl;
cout<<"\nEnter the year of
publication:\t";
cin>>date_of_publication[lib];
outfile << date_of_publication[lib] << endl;
cout<<"\nEnter date of book
issued:\t";
cin.ignore();
cin>>date_of_submission[lib];
outfile << date_of_submission[lib] << endl;
cout<<"\nEnter return date
of a book:\t";
cin.ignore();
cin>>return_date[lib];
outfile << return_date[lib] << endl<<endl;
outfile.close();
return lib;
}
void putdata(int lib)
{
user::putdata(lib);
cout<<"\n\n*\\BOOK DETAILS ARE\\*" ;
cout<<endl;
cout<<"\nThe name of a book is: "<<book_name[lib]<<endl;
cout<<"\nThe name of author is: "<<author_name[lib]<<endl;
cout<<"\nThe year of publication is: "<<date_of_publication[lib]<<endl;
cout<<"\nThe date of
submission of a book is: "<<date_of_submission[lib]<<endl;
cout<<"\nThe return date of book is: "<<return_date[lib]<<endl;
}
};
class late:public book
{
public:
string line;
int pay;
int offset;
int getdata()
{
cout<<"Enter Library No:";
cin>>lib_no;
cout<<"Enter Date of Book returned: ";
cin>>returned_date[lib_no];
if(return_date[lib_no]==0)
{
cout<<"\n\n No person exist with this library
number\n\n";
return 0;
}
else
{
int late_date =
returned_date[lib_no] - return_date[lib_no];
pay = fine * late_date;
return pay;
}
}
void putdata(int fine)
{
cout<<fine<<endl;
}
};
void main()
{
int choice,y;
book
b1;
user
u1;
late
l1;
int lib;
int fine;
for(int i = 0; i <50;i++){return_date[i]=0;}
XYZ:
cout<<"\n\n*****************************************\n";
cout<<"*\tWant to issue book.. PRESS : 1"<<endl;
cout<<"*\tWant to return book..PRESS : 2"<<endl;
cout<<"*\tFor exit
.. PRESS : 3"<<endl;
cout<<"\n*****************************************\n\n";
cout<<"Enter a choice:\t";
cin>>choice;
switch (choice )
{
case 1:
cout<<"*\\USER DETAILS ARE\\*" ;
cout<<endl;
lib = b1.getdata();
cout<<endl;
system("CLS");
cout<<endl;
cout<<endl;
cout<<"...*\\ Showing User and Book Details\\*...\n";
cout<<endl;
cout<<"\n*\\USER DETAILS ARE\\*\n\n" ;
cout<<endl;
b1.putdata(lib);
cout<<endl;
break;
case 2:
cout<<"*\\BOOK Returned DETAILS ARE\\*";
cout<<endl;
fine = l1.getdata();
cout<<endl;
if(fine!=0){
cout<<"Payable Fine is=";
l1.putdata(fine);
cout<<endl;}
break;
case 3:
system("pause");
exit(1);
break;
default:
cout<<("invalid choice");
}
cout<<"Show main menu again,,";
cout<<"press 1:\t";
cin>>y;
system("CLS");
if(y==1)
{
goto XYZ;
}
system("pause");
}
0 comments:
Post a Comment