search help
hi,
i am trying to make my program achive the following:
* allow a book to be issued to a user
* allow a book to be returned by a user
* allow the library staff to search for a book by author, to report whether it is currently in stock or on loan and to indicate in which area of the library it may be found.
any help would be much appreciated thank you.
so far this is what my program looks like:
#include <iostream>
#include <fstream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <string>
using namespace std;
const int ACC_MAX = 1000 ;
enum MemberType { Annual, Quarterly } ;
//enum Month { Jan, Feb, Mar, Apr, May, Jun,
// Jul, Aug, Sep, Oct, Nov, Dec } ;
struct Date
{
int day;
int month;
int year;
};
struct Name
{
string first_name;
string surname;
};
struct Address
{
string house_no;
string streetname;
string streettype;
string town;
};
struct libraryMember
{
Name name;
Address address;
MemberType member;
Date date;
};
void process( libraryMember a )
{
switch( a.member )
{
case Quarterly:
a.date.month += 1;
break ;
case Annual:
a.date.year += 1;
break ;
}
}
void readFile()
{
// assert( argc >= 2 ) ;
ifstream clientfile( "clients.dat" ) ;
libraryMember member[ACC_MAX] ;
int nRead = 0 ;
string text;
int nMember;
int MembershipNo;
clientfile >> nMember >> text >> text >> text;
// read data from file and store in the array 'member'
do
{
clientfile >> member[nRead].name.first_name
>> member[nRead].name.surname
>> member[nRead].address.house_no
>> member[nRead].address.streetname
>> member[nRead].address.streettype
>> member[nRead].address.town
>> MembershipNo >> text >> text
>> member[nRead].date.day
>> member[nRead].date.month
>> member[nRead].date.year;
if ( MembershipNo == 12)
member[nRead].member = Quarterly;
else
member[nRead].member = Annual;
if ( clientfile )
{
cout << member[nRead].name.first_name << " "
<< member[nRead].name.surname << " "
<< member[nRead].address.house_no << " "
<< member[nRead].address.streetname << " "
<< member[nRead].address.streettype << " "
<< member[nRead].address.town << " "
<< member[nRead].member << ". "
<< member[nRead].date.day << " "
<< member[nRead].date.month << " "
<< member[nRead].date.year << " \n";
nRead++ ;
}
} while ( clientfile && nRead < ACC_MAX ) ;
cout << nRead << " accounts read\n" ;
// printf("dfdasf");
clientfile.close() ;
}
int main()
{
int menu_selection;
cout << "\n"
<< "================================================= ================\n"
<< " Welcome to fadi younes library system\n"
<< " Bellow is the main menu for the library system\n"
<< " Thank you for choosing public library\n"
<< "================================================= ================\n"
<< " \n"
<< " \n"
<< "Select 1: To view current clients\n"
<< "Select 2: To view current books in library\n"
<< "Select 3: To perform a search through the data for\n"
<< " customers with how many books on loan\n"
<< "Select 4: Exit this program\n\n";
cin >> menu_selection;
switch (menu_selection)
{
case 1:
cout << "\n";
// needs code to read data file
readFile();
cout << "\n";
void current_client();
{
int main();
{
cout <<"Name ; Address ;Membership No"<<endl;
cout <<"---------------------------------------------------------------;"<<endl;
cout <<"achillios ; 27;old road ;10096"<<endl;
cout <<"bains ; 3;cirrus crescent ;24397"<<endl;
cout <<"christie ; 87;henley deane ;20296"<<endl;
cout <<"deaton ; 4;binney road ;13298"<<endl;
cout <<"edwards ; 19;waterlow street ;17294"<<endl;
cout <<"fishman ; 1;primrose grove ;37502"<<endl;
cout <<"george ; 31;church farm road ;42402"<<endl;
cout <<"griffiths ; 68;ware street ;31095"<<endl;
cout <<"hackett ; 17;maryland drive ;49502"<<endl;
cout <<"hatton ;156;all saints road ;37102"<<endl;
cout <<"ibbotsen ; 13;orchard street ;12293"<<endl;
cout <<"jenkins ; 8;longham copse ;10795"<<endl;
cout <<"khayer ; 85;olivers mill ;43301"<<endl;
cout <<"laskow-pooley ; 42;cedar grove ;11795"<<endl;
cout <<"montgomery ; 5;nursery avenue ;27501"<<endl;
main();
case 2:
void current_client();
{
int main();
{
cout <<"Name Of Author ;Name Of Book ;ISBN No"<<endl;
cout <<"---------------------------------------------------------------;"<<endl
;cout <<"Forsyth, Frederick ;The fist of god ;A;102391" <<endl;
cout <<"Follett, Ken ;The pillars of the earth ;A;103795" <<endl;
cout <<"Francis, Clare ;Wolf winter ;A;112424" <<endl;
cout <<"Smith, Wilbur ;A falcon flies ;A;151395" <<endl;
cout <<"Forsyth, Frederick ;The day of the jackal ;A;159151" <<endl;
cout <<"Blackmore, R.D. ;Lorna Doone ;A;193292" <<endl;
cout <<"Smith, Wilbur ;Men of men ;A;292351" <<endl;
cout <<"Smith, Wilbur ;The angels weep ;A;482315" <<endl;
cout <<"James, P.D. ;Cover her face ;D;144371" <<endl;
cout <<"James, P.D. ;Devices and desires ;D;193395" <<endl;
cout <<"Kellerman, Faye ;Stone kiss ;D;434517" <<endl;
cout <<"James, P.D. ;The skull beneath the skin ;D;439518" <<endl;
cout <<"Kelly, Jim ;The water clock ;D;543951" <<endl;
cout <<"Hoag, Tami ;Dark horse ;D;664333" <<endl;
cout <<"Cookson, Catherine ;The silent lady ;R;151611" <<endl;
cout <<"Cookson, Catherine ;Kate hannigans girl ;R;165163" <<endl;
cout <<"Thompson, E.V. ;The lost years ;R;165213" <<endl;
cout <<"Steel, Danielle ;The cottage ;R;177516" <<endl;
cout <<"Binchley, Maeve ;Quentins ;R;261561" <<endl;
cout <<"Alcott, Louisa ;Little women ;R;395104" <<endl;
cout <<"Cookson, Catherine ;Rosie of the river ;R;512843" <<endl;
cout <<"Asimov, Isaac ;Foundation ;S;165108" <<endl;
cout <<"Barker, Clive ;Imajica ;S;172816" <<endl;
cout <<"Barker, Clive ;The great and secret show ;S;174427" <<endl;
cout <<"Barker, Clive ;Weaveworld ;S;282118" <<endl;
cout <<"Clarke, Arthur C ;2001 A space odessy ;S;294561" <<endl;
cout <<"Asimov, Isaac ;Foundation and empire ;S;313178" <<endl;
cout <<"Asimov, Isaac ;Second foundation ;S;549201" <<endl;
case 3:
break;
case 4:
cout << "Thank you for using public library at the university of westminster\n";
cout << " \n";
cout << "program director\n";
cout << "fadi younes\n";
//exit(1);
break;
}
}
}
}
}
}
|