1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include<iomanip>
using namespace std;
struct openaccount
{
string name;
string lastname;
string phonenumber;
string address;
string city;
int postcode;
int accountnumber;
double balance;
double movies;
};
void openacc(openaccount[],int&);
void closeacc(openaccount[],int&);
void deposit(openaccount[],int&);
void printresult(openaccount[],int&);
void rentmovie(openaccount[],int&);
void returnmovie(openaccount[],int&);
void accountinfo(openaccount[],int&);
void searchforaccount(openaccount[],int&);
double quit(openaccount[],int&,char&,ofstream&);
int main()
{
const int size=100;
char choice='d';
char response;
string filename;
ifstream infile;
ofstream outfile;
openaccount information[size];
int personcount=0;
cout<<"Enter file to open: "<<endl;
cin>>filename;
cout<<filename.c_str();
infile.open(filename.c_str());
if(!infile.fail()){
cout<<"File exists. Overwrite (y or n)?"<<endl;
cin>>response;
}
else
cout<<"The was created."<<endl;
if('n'==tolower(response))
{
cout<<"Goodbye"<<endl;
return 1;
}
while(choice!='q')
{
cout<<"o: Open account"<<endl;
cout<<"c: Close account"<<endl;
cout<<"d: deposit"<<endl;
cout<<"r: Rent Movie"<<endl;
cout<<"t: Return Movie"<<endl;
cout<<"a: Account info"<<endl;
cout<<"p: Print all accounts"<<endl;
cout<<"s: Search for account"<<endl;
cout<<"q: quit"<<endl;
cout<<"Enter operation"<<endl;
cin>>choice;
cin.ignore();
//do{
//cin>>choice;
//cin.ignore();
//}
//while (choice!='o'||choice!='c'||choice!='d'||choice!='r'||choice!='t'||choice!='a'||choice!='p'||choice!='s'||choice!='q');
switch(choice)
{
case 'o':
openacc(information,personcount);
break;
case 'c':
closeacc(information,personcount);
case 'd':
deposit(information,personcount);
break;
case 'p':
printresult(information,personcount);
break;
case 'r':
rentmovie(information,personcount);
break;
case 't':
returnmovie(information,personcount);
break;
case 'a':
accountinfo(information,personcount);
break;
case 's':
searchforaccount(information,personcount);
break;
case 'q':
quit(information,personcount,choice,outfile);
break;
}
}
return 0;
}
|