Ok here is the code I am working with I have tried to do this butcannot find out
ID: 3618280 • Letter: O
Question
Ok here is the code I am working with I have tried to do this butcannot find out what is making it loop over and over. If you entermenu choice 1 it goes thru all of the questions and when you answerthem all it just displays the menu and address city state zip coutsover and over infinitely. choice 2 does what it is supposed tountil you get to the same point as choice one then it does the sameas choice 1. choice 3 doesnt display the info in the array it justdisplays the menu over again. choice 4 works... It may be in thebrackets as well as the loops or function calls IDK???Please help me with this one this is my last c++ programever.... I need this asap:
#include <iostream> #include <string> using namespace std;
struct customerAccount { string Name; string Address; string City_State_Zip; double TelNo; double AcBalance; string D_Payment; };
//Function Prototype void Display (customerAccount ca[],int s);
//start main int main() { customerAccount customers[20]; int choice,i=0,size=0; do { cout<<" Menu "<<endl; cout<<"1. Enter data into an array"<<endl; cout<<"2. Modify contents"<<endl; cout<<"3. Display contents"<<endl; cout<<"4. Exit"<<endl; cout<<"Please enter a choice"<<endl; cin>>choice; switch(choice) { case 1: // inputting data of customer cout<<"Enter Customer Name: "; cin>>customers[1].Name; fflush (stdin); cout<<"Enter your address: "; cin>>customers[i].Address; fflush (stdin); cout<<"Enter your City, State and Postal code:"; cin>>customers[i].City_State_Zip; fflush (stdin); cout<<"Enter your telephone #:"; cin>>customers[i].TelNo; cout<<"Enter your account balance:"; cin>>customers[i].AcBalance; //input validation if (customers[i].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, PleaseContinue:"<<endl; cin>>customers[i].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[i].D_Payment; i++; break; case 2: int ele; //inputting element to be modified cout<<"Enter the element you wish to modify:"; cin>>ele; //inputting data into the element cout<<"Re-enter the data of the element you wish tomodify:"<<endl; cout<<"Enter Customer Name:"; cin>>customers[ele-1].Name; cout<<"Enter Address:"; cin>>customers[ele-1].Address; cout<<"Enter your City, State and Postal Code: "; cin>>customers[ele-1].City_State_Zip; fflush (stdin); cout<<"Enter Your Telephone #:"; cin>>customers[ele-1].TelNo; cout<<"Enter your account balance:"; cin>>customers[ele-1].AcBalance; //validation again if (customers[ele-1].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, ReEenter:"<<endl; cin>>customers[ele-1].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[ele-1].D_Payment; break; case 3: // function call to display contents Display (customers,i); break; case 4: exit(0); break; } //ending the switch
}while(choice!=4);//ending do while loop system ("pause");
return 0; } void Display (customerAccount ca[],int s) { // displaying data
for (int i=0;i<s;i++) { cout<<" Customer Name: "; cout<<ca[i].Name<<endl; cout<<" Address: "; cout<<ca[i].Address<<endl; cout<<" City, State, Postal: "; cout<<ca[i].City_State_Zip<<endl; cout<<" Telephone #: "<<endl; cout<<ca[i].TelNo<<endl; cout<<" Account Balance: "; cout<<ca[i].AcBalance<<endl; cout<<" Date of Last Patment: "; cout<<ca[i].D_Payment<<endl; } }
Please help me with this one this is my last c++ programever.... I need this asap:
#include <iostream> #include <string> using namespace std;
struct customerAccount { string Name; string Address; string City_State_Zip; double TelNo; double AcBalance; string D_Payment; };
//Function Prototype void Display (customerAccount ca[],int s);
//start main int main() { customerAccount customers[20]; int choice,i=0,size=0; do { cout<<" Menu "<<endl; cout<<"1. Enter data into an array"<<endl; cout<<"2. Modify contents"<<endl; cout<<"3. Display contents"<<endl; cout<<"4. Exit"<<endl; cout<<"Please enter a choice"<<endl; cin>>choice; switch(choice) { case 1: // inputting data of customer cout<<"Enter Customer Name: "; cin>>customers[1].Name; fflush (stdin); cout<<"Enter your address: "; cin>>customers[i].Address; fflush (stdin); cout<<"Enter your City, State and Postal code:"; cin>>customers[i].City_State_Zip; fflush (stdin); cout<<"Enter your telephone #:"; cin>>customers[i].TelNo; cout<<"Enter your account balance:"; cin>>customers[i].AcBalance; //input validation if (customers[i].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, PleaseContinue:"<<endl; cin>>customers[i].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[i].D_Payment; i++; break; case 2: int ele; //inputting element to be modified cout<<"Enter the element you wish to modify:"; cin>>ele; //inputting data into the element cout<<"Re-enter the data of the element you wish tomodify:"<<endl; cout<<"Enter Customer Name:"; cin>>customers[ele-1].Name; cout<<"Enter Address:"; cin>>customers[ele-1].Address; cout<<"Enter your City, State and Postal Code: "; cin>>customers[ele-1].City_State_Zip; fflush (stdin); cout<<"Enter Your Telephone #:"; cin>>customers[ele-1].TelNo; cout<<"Enter your account balance:"; cin>>customers[ele-1].AcBalance; //validation again if (customers[ele-1].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, ReEenter:"<<endl; cin>>customers[ele-1].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[ele-1].D_Payment; break; case 3: // function call to display contents Display (customers,i); break; case 4: exit(0); break; } //ending the switch
}while(choice!=4);//ending do while loop system ("pause");
return 0; } void Display (customerAccount ca[],int s) { // displaying data
for (int i=0;i<s;i++) { cout<<" Customer Name: "; cout<<ca[i].Name<<endl; cout<<" Address: "; cout<<ca[i].Address<<endl; cout<<" City, State, Postal: "; cout<<ca[i].City_State_Zip<<endl; cout<<" Telephone #: "<<endl; cout<<ca[i].TelNo<<endl; cout<<" Account Balance: "; cout<<ca[i].AcBalance<<endl; cout<<" Date of Last Patment: "; cout<<ca[i].D_Payment<<endl; } } #include <iostream> #include <string> using namespace std;
struct customerAccount { string Name; string Address; string City_State_Zip; double TelNo; double AcBalance; string D_Payment; };
//Function Prototype void Display (customerAccount ca[],int s);
//start main int main() { customerAccount customers[20]; int choice,i=0,size=0; do { cout<<" Menu "<<endl; cout<<"1. Enter data into an array"<<endl; cout<<"2. Modify contents"<<endl; cout<<"3. Display contents"<<endl; cout<<"4. Exit"<<endl; cout<<"Please enter a choice"<<endl; cin>>choice; switch(choice) { case 1: // inputting data of customer cout<<"Enter Customer Name: "; cin>>customers[1].Name; fflush (stdin); cout<<"Enter your address: "; cin>>customers[i].Address; fflush (stdin); cout<<"Enter your City, State and Postal code:"; cin>>customers[i].City_State_Zip; fflush (stdin); cout<<"Enter your telephone #:"; cin>>customers[i].TelNo; cout<<"Enter your account balance:"; cin>>customers[i].AcBalance; //input validation if (customers[i].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, PleaseContinue:"<<endl; cin>>customers[i].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[i].D_Payment; i++; break; case 2: int ele; //inputting element to be modified cout<<"Enter the element you wish to modify:"; cin>>ele; //inputting data into the element cout<<"Re-enter the data of the element you wish tomodify:"<<endl; cout<<"Enter Customer Name:"; cin>>customers[ele-1].Name; cout<<"Enter Address:"; cin>>customers[ele-1].Address; cout<<"Enter your City, State and Postal Code: "; cin>>customers[ele-1].City_State_Zip; fflush (stdin); cout<<"Enter Your Telephone #:"; cin>>customers[ele-1].TelNo; cout<<"Enter your account balance:"; cin>>customers[ele-1].AcBalance; //validation again if (customers[ele-1].AcBalance<0) { cout<<"Account Balances Must Be a Positive #, ReEenter:"<<endl; cin>>customers[ele-1].AcBalance; } cout<<"Enter Date of Last Payment:"; cin>>customers[ele-1].D_Payment; break; case 3: // function call to display contents Display (customers,i); break; case 4: exit(0); break; } //ending the switch
}while(choice!=4);//ending do while loop system ("pause");
return 0; } void Display (customerAccount ca[],int s) { // displaying data
for (int i=0;i<s;i++) { cout<<" Customer Name: "; cout<<ca[i].Name<<endl; cout<<" Address: "; cout<<ca[i].Address<<endl; cout<<" City, State, Postal: "; cout<<ca[i].City_State_Zip<<endl; cout<<" Telephone #: "<<endl; cout<<ca[i].TelNo<<endl; cout<<" Account Balance: "; cout<<ca[i].AcBalance<<endl; cout<<" Date of Last Patment: "; cout<<ca[i].D_Payment<<endl; } }
Explanation / Answer
please rate - thanks some of your types, input and indices were wrong try this #include #include using namespace std; struct customerAccount { string Name; string Address; string City_State_Zip; string TelNo; double AcBalance; string D_Payment; }; //Function Prototype void Display (customerAccount ca[],int s); //start main int main() { customerAccount customers[20]; int choice,i=0,size=0; do { coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.