Question

Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for a new account is entered, be sure the user enters data for all the fields. No negative account balances should be entered.
0 2
Add a comment Improve this question Transcribed image text
Answer #1


#include

#include

using namespace std;


struct customer{ //customer structure datatype

string name, address, city, state, zip, telephone, date;

int balance;

};


void setCustomer(customer&); //inputs customer data from user

void getCustomer(customer); //prints customer data to the screen


int main()

{

int size,action=1;


cout<<"-+- Customer Manager -+-\nHow many customers?:\t";

cin>>size;

customer*database=new customer[size];

cout<<"\n --- Created database of "<


while(action!=0){ //Menu Interface Loop

cout<<"-+- Menu -+-\n 0: Quit\n 1: Set a customer's information\n 2: Display a customer's information\n\n>";

cin>>action;

cout<

switch(action){

case 1:{

int cnum;

cout<<"customers:\n";

for(int x=0;x

cout<

cout<<"\ncustomer number to change:\t";

cin>>cnum;

if(cnum<=size && cnum>0)

setCustomer(database[cnum-1]);

else

cout<<"\ninvalid customer number!\n\n";

}

break;

case 2:{

int cnum;

cout<<"customers:\n";

for(int x=0;x

cout<

cout<<"\ncustomer number to display:\t";

cin>>cnum;

if(cnum<=size && cnum>0)

getCustomer(database[cnum-1]);

else

cout<<"\ninvalid customer number!\n\n";

}

break;

default: break;

}

}

delete[] database;

return 0;

}


void setCustomer(customer&set)

{

cout<<"Enter Data for the Customer:\nName:\t\t\t";

cin>>set.name;

cout<<"Address:\t\t";

cin.ignore(256,'\n');

getline(cin, set.address);

cout<<"City:\t\t\t";

cin>>set.city;

cout<<"State:\t\t\t";

cin>>set.state;

cout<<"Zip Code:\t\t";

cin>>set.zip;

cout<<"Telephone Number:\t";

cin>>set.telephone;

cout<<"Date of last Payment:\t";

cin>>set.date;

do{

cout<<"Account Balance:\t";

cin>>set.balance;

if(set.balance<0)

cout<<"Invalid Balance!\n";

}while(set.balance<0); //data validation

}


void getCustomer(customer get)

{

cout<<"\n --- Data for "<

cout<<"\nAddress:\t"<

cout<<"\nTelephone:\t"<

cout<<"\nLast Payment:\t"<

cout<<"\nAccount balance:\t"<

}

Add a comment
Answer #2
Follow : http://www.dreamincode.net/forums/topic/80834-struct-with-arrays-in-functions/
Add a comment
Answer #3
#include 002 #include 003 #include 004 005 006 using namespace std; 007 008 void menu(); 009 void acc(string ,int AcArray[30]); //c for customer number. 010 void display(string , int AcArray[30]); 011 void editBalance(string,int AcArray[30]); 012 void displayBalance(); 013 014 015 struct customer 016 { 017 string name; 018 string address; 019 string city; 020 string state; 021 string zip; 022 string tele; 023 //double acc; 024 char date[20]; 025 double balance; 026 027 }; 028 029 030 031 int main(int argc, char *argv[]) 032 { 033 const int MaxAccounts = 30; 034 int customer AcArray[MaxAccounts]; 035 036 menu; 037 038 editBalance( AcArray, MaxAccounts ); 039 040 displayBalance( AcArray, MaxAccounts ); 041 042 043 044 system("PAUSE"); 045 return EXIT_SUCCESS; 046 } 047 048 void menu 049 { 050 int choice; 051 //char YN; 052 053 cout << "Welcome to you bank company that has lost all your money. " << endl; 054 sleep(1000); 055 cout << "Please choose an action from the menu displayed below." << endl; 056 cout << "Press 1 to enter a new account(s)." << endl; 057 cout << "Press 2 to see current balance." << endl; 058 cout << "Press 3 to edit current balance." << endl; 059 cout << "Press 4 to exit." << endl; 060 cin >> choice 061 062 switch(choice) 063 { 064 case 1: 065 acc; 066 break; 067 068 case 2: 069 cout << "current account balances are " << customer[c].acc << endl; 070 bool more() 071 { 072 cout << "Continue (y/n) ? "; 073 int reply = cin.get(); 074 return !(reply=='n' || reply=='N'); 075 } 076 break; 077 078 case 3: 079 editBalance; 080 break; 081 082 case 4: 083 return 0; 084 break; 085 086 } 087 } 088 089 double acc(customer AcArray[], const int MaxAccounts ) 090 { 091 //int c; 092 int total; 093 //char YN; 094 095 cout << "How many customers would you like to enter?" << endl; 096 cin >> total; 097 098 for(int c = 0; c < total; c++) 099 { 100 cout << "Enter the name( First Last) of customer " << total; 101 cin >> AcArray[c].name; 102 //validate 103 104 cout << "Enter the adress(i.e. 4758 nw 0 st) of customer " << total; 105 cin >> AcArray[c].address; 106 //validate 107 108 cout << "Enter the city(i.e. Florida) of customer " << total; 109 cin >> AcArray[c].city; 110 //validate no numbers 111 112 cout << "Enter the state(i.e. FL) of customer " << total; 113 cin >> AcArray[c].state; 114 //validate 2 letters only! 115 116 cout << "Enter the 5 digit zip code(i.e.12345) of customer " << total; 117 cin >> AcArray[c].zip; 118 //validate 5 numbers 119 120 cout << "Enter the telephone number(ie. 123-456-7890) of customer " << total; 121 cin >> AcArray[c].tele; 122 //validate no letters. 123 124 cout << "Enter the current account balance of customer " << total; 125 cin >> AcArray[c].balance; 126 //validate double && non-neg 127 128 cout << "Enter the Date(i.e. 11 05 2009) of the last payment of customer " << total; 129 cin >> AcArray[c].date; 130 //validate 131 } 132 /* cout << endl; 133 cout << "Would you like to return to the menu(y or n): "; 134 cin >> YN*/ 135 136 bool more() 137 { 138 cout << "Continue (y/n) ? "; 139 int reply = cin.get(); 140 return !(reply=='n' || reply=='N'); 141 } 142 143 144 } 145 146 147 void display(string, int c, int AcArray[]) 148 { 149 for(int c = 0; c < total; c++) 150 { 151 152 cout << "Customer " << c << " account information: " << endl; 153 cout << endl; 154 cout << "The customer's name is " << AcArray[c].name << endl; 155 cout << AcArray[c].name <<"'s address is " << AcArray[c].address << endl; 156 cout << AcArray[c].name <<" is currently living in the city " << AcArray[c].city << endl; 157 cout << AcArray[c].name <<" is currently living in the state of " << AcArray[c].state << endl; 158 cout << AcArray[c].name <<"'s zip code is " << AcArray[c].zip << endl; 159 cout << AcArray[c].name <<"'s telephone number is " << AcArray[c].tele << endl; 160 cout << AcArray[c].name <<"'s current account balance is " << AcArray[c].balance << endl; 161 cout << "The last day "<< AcArray[c].name <<" paid was " << AcArray[c].date << endl; 162 163 } 164 switch(YN) 165 { 166 case y: 167 menu; 168 break; 169 170 case n: 171 return 0; 172 } 173 } 174 175 void editBalance( account AcArray[], const int MaxAccounts ) //Display each account seperaetely 176 { 177 for( int c = 0; c < MaxAccounts; c++ ) 178 AcArray[c].balance = c; 179 } 180 181 void displayBalance( account AcArray[], const int MaxAccounts ) 182 { 183 for( int c = 0; c < MaxAccounts; c++ ) 184 cout << AcArray[c].balance; 185 186 bool more() 187 { 188 cout << "Continue (y/n) ? "; 189 int reply = cin.get(); 190 return !(reply=='n' || reply=='N'); 191 } 192 }
Add a comment
Know the answer?
Add Answer to:
Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that keeps track of a speakers’ bureau. The program should use a structure...

    Write a program that keeps track of a speakers’ bureau. The program should use a structure to store the following data about a speaker: (this is in C++) Name Telephone Number Speaking Topic Fee Required The program should use a vector of structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the vector. The program should have a menu-driven user interface. Input Validation: When the...

  • Write a program (C++) that shows Game sales. The program should use a structure to store...

    Write a program (C++) that shows Game sales. The program should use a structure to store the following data about the Game sale: Game company Type of Game (Action, Adventure, Sports etc.) Year of Sale Sale Price The program should use an array of at least 3 structures (3 variables of the same structure). It should let the user enter data into the array, change the contents of any element and display the data stored in the array. The program...

  • Customer Accounts This program should be designed and written by a team of students. Here are...

    Customer Accounts This program should be designed and written by a team of students. Here are some suggestions: Write a program that uses a structure to store the following information about a customer account: • Name • Address • City, state, and ZIP • Telephone number • Account balance • Date of last payment The structure should be used to store customer account records in a file. The program should have a menu that lets the user perform the following...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • please write in C++ Write a program that uses a structure to store the following inventory...

    please write in C++ Write a program that uses a structure to store the following inventory data in a file: The data can be either read from a text file or the keyboard Item name (string) Quantity on hand(int) Wholesale cost(double) Retail Cost(double) The program should have a menu that allows the user to perform the following tasks: Add new records to the file Display any record in the file User will provide the name of the item or the...

  • Inventory Program (C++) Write a program that uses a structure to store the following inventory data...

    Inventory Program (C++) Write a program that uses a structure to store the following inventory data in a file: - Item Description -Quantity on Hand -Wholesale cost -Retail cost -Date Added to Inventory The program should have a menu that allows the user to perform the following tasks: -Add new records to file -Display any record in the file -Change any record in the file Input Validation: The program should not accept quantities, or wholesale or retail costs, less than...

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Write a code using python to make an Agenda that can store values such as Name,...

    Write a code using python to make an Agenda that can store values such as Name, Address and Phone number of 10 digits Name format First, Last Address Format Street, Number Zip City ST. Country phone format (###) ###-#### This program should give the option of adding a new contact or Display all the contacts you have stored by typing New Contact or Display Contacts

  • Need a program in python. Asterix and Obelix want to store and process information about movies...

    Need a program in python. Asterix and Obelix want to store and process information about movies they are interested in. So, you have been commissioned to write a program in Python to automate this. Since they are not very computer literate, your program must be easy for them to use. They want to store the information in a comma separated text file. Using this they would need to generate a report – see all items AND show a bar chart...

  • in java (Bank Account) Write a program that inputs in the full name, street address, city, state, zip code, and social...

    in java (Bank Account) Write a program that inputs in the full name, street address, city, state, zip code, and social security for new account. In addition, it inputs in the initial account balance and allows the owner of the new account to make one withdrawal followed by one deposit. Your program should calculate the ending balancing after the withdrawal and deposit made by the account holder. It should also find the count of each one of these bills $78,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT