Documente Academic
Documente Profesional
Documente Cultură
#include<cmath>
#include<string>
#include <stdio.h> //libraries for strcmp on unix/linux
#include <string.h> //libraries for strcmp on unix/linux
int Read_a_customer();
int Print_details_of_a_customer();
int Return_the_number_of_the_customers();
struct CustomerDetails
{
char name[40];
char address[40];
char ID[40];
char title[40];
char author[40];
char ISBN[40]; //BookDetails STRUCT Variables
char status[40];
char date[40];
}date;
struct BookDetails
{
char title[40];
char author[40];
char ISBN[40]; //BookDetails STRUCT Variables
char status[40];
char date[40];
CustomerDetails T;
CustomerDetails F;
};
BookDetails failure_c;
BookDetails c;
BookDetails Array_c[10];
BookDetails failure_d;
BookDetails d;
BookDetails Array_d[10];
BookDetails input;
BookDetails output;
int number_customer = 0;
int const MAX = 100;
char temp[40];
int main()
{
char opt;
switch (opt){
int Read_a_customer()
{
char opt;
cout<<endl;
for(int i=0;i<1;i++)
{
cin.ignore();
cout <<"\nPlease enter the customer ID: ";
cin.getline(Array_c[i+1].T.ID,40);
cout <<"Hit Enter..!!";
cin.ignore();
cout <<"\nPlease enter the customer name : ";
cin.getline(Array_c[i].T.name,40);
cout <<"Hit Enter..!!";
cin.ignore();
cout <<"\nPlease enter the customer address : ";
cin.getline(Array_c[i].T.address,40);
cout <<"Hit Enter..!!";
if (opt!='y' || opt!='Y')
{
cout<<endl;
cout <<"The customer with ID: "<< Array_c[i].T.ID << " was
added"<<endl;
return main();
}
else
if (opt!='n' || opt!='N'){
cout <<"Error argument. you will now return into main
menu..memory location reset. Nothing to save..!!!"<<endl;
Array_c[i] = failure_c;
Array_d[i] = failure_d;
return main();
}
else
cin.ignore();
cout << "\nPlease enter the title of the book: ";
cin.getline(d.F.title,40);
cout <<"Hit Enter..!!";
cin.ignore();
cout << "\nPlease enter the author of the book: ";
cin.getline(d.F.author,40);
cout <<"Hit Enter..!!";
cin.ignore();
cout << "\nPlease enter the ISBN of the book: ";
cin.getline(d.F.ISBN,40);
cout <<"Hit Enter..!!";
cin.ignore();
cout << "\nPlease enter the date that you borrow the book? (30-12-
2012): ";
cin.getline(d.F.date,40);
strcpy(temp,Array_c[i].T.ID);
}
cout << "\nThe customer with ID: "<< c.T.ID << " was added. Customer also
booked 1 book with ISBN: "<<d.F.ISBN<<" on "<< d.F.date<<" date";
cout <<"------"<<endl;
for(int i=0;i<3;i++)
if (strcmp(Array_c[i].T.name,Array_c[i+1].T.name)>0)
{
strcpy(temp,Array_c[i+1].T.name);
strcpy(Array_c[i+1].T.name,Array_c[i].T.name);
strcpy(Array_c[i+1].T.name,temp);
}
cout <<endl;
return main();
}
int Print_details_of_a_customer()
{
const int max=100;
cout << "***************************"<<endl;
cout << "Print Details Of A Customer"<<endl;
cout << "***************************"<<endl;
cin.ignore();
cout <<"Please enter the ID of a customer: ";
cin.getline(c.T.ID,40);
for(int i=0;i<max;i++)
{
if (strcmp(Array_c[i].T.ID,Array_c[i+1].T.ID)>0){
cout <<"The customer with ID: "<<c.T.ID<< " has the following
details:"<<endl;
cout <<"Name: "<<Array_c[i].T.name<<endl;
cout <<"Address: "<<Array_c[i].T.address<<endl;
cout <<"---------"<<endl;
}
else
cout <<"There isn't any customer with
this ID: "<<c.T.ID<<endl;}
return main();
}