Question: Please help fix this issue. It's saying when executed, your code tried to create an excessively large file. A common cause for this is an
Please help fix this issue. It's saying when executed, your code tried to create an excessively large file. A common cause for this is an infinite loop. Carefully check the condition and the loop body of any loop that does output. Question is below.
Code:
#include
#include
using namespace std;
#include
struct CustomerAccount
{
string customerName;
string customerAddress;
string city;
string state;
int zip_code;
long long telephone;
double accountBalance;
string last_payment_date;
};
int main()
{
int choice, index = 0;
int customerNumber;
// checking if there is any account
bool valid = false;
struct CustomerAccount accountObject[20];
while (choice != 4)
{
cout << endl;
// displaying menu
cout << "**************MENU************" << endl;
cout << " 1. Enter new account information" << endl;
cout << "2. Change account information" << endl;
cout << "3. Display all account information" << endl;
cout << "4. Exit the program " << endl;
cout << endl;
cout << "Enter choice :";
cin >> choice;
cin.ignore();
switch (choice)
{
case 1:
{
cout << "EntercustomerName :";
cin >> accountObject[index].customerName;
cin.ignore();
cout << "Enter customerAddress :" ;
cin >> accountObject[index].customerAddress;
cout << "Enter city :";
cin >> accountObject[index].city;
cout << "Enter state :";
cin >> accountObject[index].state;
cout << "Enter Zip code :";
cin >> accountObject[index].zip_code;
cout << "Enter mobile number :";
cin >> accountObject[index].telephone;
cout << "Enter account Balance :";
cin >> accountObject[index].accountBalance;
cout << "Enter last payment date :";
cin >> accountObject[index].last_payment_date;
cout << "You have entered information for customer number " << index << endl;
valid = true;
index++;
break;
}
case 2:
{
while (1)
{
if(valid != 0){
cout << "Enter customer number :";
cin >> customerNumber;
if (customerNumber < 0 || customerNumber >= index)
{
cout << "Invalid.Must be greater than or equal to 0 and less than " << index << endl;
continue;
}else{
cout << endl << endl;
cout << "Customer customerName :" << accountObject[customerNumber].customerName << endl;
cout << "Customer customerAddress:" << accountObject[customerNumber].customerAddress << endl;
cout << "City:" << accountObject[customerNumber].city << endl;
cout << "State:" << accountObject[customerNumber].state << endl;
cout << "Zip code :" << accountObject[customerNumber].zip_code << endl;
cout << "Telephone :" << accountObject[customerNumber].telephone << endl;
cout << "Account accountBalance:" << accountObject[customerNumber].accountBalance << endl;
cout << "Date of last payment:" << accountObject[customerNumber].last_payment_date << endl;
cout << endl << endl;
cout << "Enter customerName :";
cin >> accountObject[customerNumber].customerName;
cin.ignore();
cout << "Enter customer Address :";
std::getline(std::cin, accountObject[customerNumber].customerAddress);
cout << "Enter city :";
cin >> accountObject[customerNumber].city;
cout << "Enter state :";
cin >> accountObject[customerNumber].state;
cout << "Enter Zip code :";
cin >> accountObject[customerNumber].zip_code;
cout << "Enter mobile number :";
cin >> accountObject[customerNumber].telephone;
cout << "Enter accountBalance :";
cin >> accountObject[customerNumber].accountBalance;
cout << "Enter last payment date :";
cin >> accountObject[customerNumber].last_payment_date;
break;
}
}else{
cout << "No records Found!!! Select option 1 to add the records!!!" << endl;
break;
}
}
break;
}
case 3:
{
for (int i = 0; i < index; i++)
{
cout << "Customer Name :" << accountObject[i].customerName << endl;
cout << "Customer Address:" << accountObject[i].customerAddress << endl;
cout << "City:" << accountObject[i].city << endl;
cout << "State:" << accountObject[i].state << endl;
cout << "Zip code :" << accountObject[i].zip_code << endl;
cout << "Telephone :" << accountObject[i].telephone << endl;
cout << "Account accountBalance:" << accountObject[i].accountBalance << endl;
cout << "Date of last payment:" << accountObject[i].last_payment_date << endl;
cout << "Press enter to continue..." << endl;
//system("PAUSE");
}
cout << "No account information Found!!! Select option 1 to add the records!!!" << endl;
break;
break;
}
case 4:
{
//Exiting the program
cout << "Program Exit" << endl;
exit(0);
}
default:
{
cout << "Invalid input.Must be 1 or 2 or 3" << endl;
break;
}
}
//break;
}
return 0;
}
Question:
11.7: Customer Accounts
Write aprogramthat uses a structure tostorethe following data about a customer account:
Customername
Customer address
City
State
ZIP code
Telephone
Account balance
Date of last payment
Theprogramshould use anarrayof at least 20 structures. It should let the user enter data into thearray, change the contents of anyelement, and display all the datastoredin thearray. Theprogramshould have a menu-driven user interface.
Prompts AndOutputLabels.Your main menu should be the following:
1. Enter new account information
2. Change account information
3. Display all account information
4. Exit theprogram
The user is expected to enter 1 or 2 or 3 or 4.
The main menu is displayed at the start of theprogramand after the handling of choices 1, 2 and 3.
If 1 is entered for the main menu,theprogramprompts for each of the data listed above, in the order listed above, using the above data descriptions (e.g. "ZIP code") as prompts (followed in each case by a colon). After reading in and processing the data, theprogramprints
You have entered information for customer number X
where X is the customer number: 0 for the first customer and increasing by 1 for each subsequent customer that is entered.
If 2 is entered for the main menu,theprogramprompts for the customer number:
Customer number:
Upon entering a valid customer number theprogramdisplays all the data for the particular customer that has been saved:
Customername: ...
Customer address: ...
City: ...
State: ...
ZIP code: ...
Telephone: ...
Account balance: ...
Date of last payment: ...
Theprogramthen skips one or two lines and prompts for a change, using the same prompts as inchoice 1above for all the data items associated with a customer.
If 3 is entered for the main menu,theprogramdisplays all the data for each customer that has been saved, using the display format inchoice 2above. After the display of each customer theprogramprompts "Press enter to continue..." and waits for the user to hit return.
If 4 is entered for the main menu,theprogramterminates.
Input Validation (OPTIONAL).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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
