//File : LongProgram2.cpp //Author : Andre Long //Due : September 2, 2004 //Description : This program will allow a user to enter or alter data for customer accounts #include #include using namespace std; struct Account { char Name[30]; char Address[40]; char CityStateZip[50]; char TelephoneNumber[13]; float AccountBalance; char DateOfLastPayment[11]; }; int Menu(); Account EnterData( Account[20] ); Account ModifyData( Account[20] ); void DisplayData( Account[20] ); int main () { int choice; int accountNumber; Account customer[20]; for(int i=0; i<20; i++) //initialize stucture of arrays with dummy information { Account somebody = {"John Doe", "1111 Main Street", "Sacramento California 95822", "916-111-2222", 0, "06/12/2004"}; customer[i]=somebody; } do { choice = Menu(); if(choice < 0) { cout<<"You must enter in a positive number"<<"\n"; } switch (choice) { case 0: cout<<"Exiting Program "; break; case 1: EnterData(customer); break; case 2: cout<<"Enter account number for one particular customer "; cin>> accountNumber; cout<<"\n"; cout<<"Enter the same number on very next line "; cout<<"\n"; ModifyData(customer); break; case 3: DisplayData(customer); break; default:"You need to enter in a choice from 0 to 3 "; } } while ( choice!=0 ); cout<<"Good Bye, Have a nice day "; } int Menu() { int choose; cout<<"Welcome to the long accounting program, your choices are: "<<"\n"; cout<<"\n"; cout<<" (0) Quit this program "<<"\n"; cout<<" (1) Enter data for all customer accounts "<<"\n"; cout<<" (2) Modify one particular customer account "<<"\n"; cout<<" (3) Display information for all accounts "<<"\n"; cin>> choose; cin.ignore(); return choose; } Account EnterData(Account tempX[]) { int flag1=1; int flag2=1; int flag3=1; int flag4=1; int flag5=1; int flag6=1; for ( int i = 0; i<20; i++ ) { do { flag1=1; cout<<"Enter name of customer "<>tempX[i].AccountBalance; cout<<"\n"; if (tempX[i].AccountBalance < 0 ) { cout<<"Account Balance can not be negative "<<"\n"; flag5=0; } } while(flag5==0); do { flag6=1; cout<<"Enter the date of last payment of customer "<> index; cin.ignore(); do { flag1=1; cout<<"Enter customer name : "; cin.getline(tempY[index].Name, 30); if ( isalpha(tempY[index].Name[0]) <= 0 ) { cout<<"Name must start with letter."<<"\n"; flag1=0; } } while(flag1==0); do { flag2=1; cout<<"Enter customer's street adress : "; cin.getline(tempY[index].Address, 40); if ( isalnum(tempY[index].Address[0]) <= 0 ) { cout<<"Addres must start with a letter or digit."<<"\n"; flag2=0; } } while(flag2==0); do { flag3=1; cout<<"Enter customer's City, State and Zip code : "; cin.getline(tempY[index].CityStateZip, 50); if ( isalnum(tempY[index].CityStateZip[0]) <= 0 ) { cout<<"Geographic address must start with a letter or digit."<<"\n"; flag3=0; } } while(flag3==0); do { flag4=1; cout<<"Enter customer's telephone number : "; cin.getline(tempY[index].TelephoneNumber, 13); if ( isdigit(tempY[index].TelephoneNumber[0]) <= 0 ) { cout<<"Telephone number must start with a number "<<"\n"; flag4=0; } } while(flag4==0); do { flag5=1; cout<<"Money in account is : "; cin>> tempY[index].AccountBalance;\ cin.ignore(); if ( tempY[index].AccountBalance < 0 ) { cout<<"Can not have a negative amount of money in account "<<"\n"; flag5=0; } } while(flag5==5); do { cout<<"What is the date of last payment : "; cin.getline(tempY[index].DateOfLastPayment, 11); if (isalnum(tempY[index].DateOfLastPayment[0]) <= 0 ) { cout<<"Date must start with a letter or number "<<"\n"; flag6=0; } } while(flag6==0); return tempY[20]; } //end function void DisplayData(Account tempZ[]) { for(int i=0; i<20; i++) { cout<<"Customer : "<