This program uses a menu interface, it is meant to hold 10 user accounts with various information. When I input things into the strings for the address, it skips the next cin. Are you not able to store multiple words in one string?
I know the code is messy so here is the part with the issue
for(int count = 0 + accountNumbers; count < customer; count++)
{
cout << "Please enter the name for account " << count +1 << endl;
cin >> person[count].name;
cout << endl;
cout << "Please enter the street address:" << endl;
cin >> person[count].addressStreet;
cout << endl;
cout <<"Please enter the city, state, and zip code:" << endl;
cin >> person[count].addressZip;
Here is the code in its entirety
const int customer = 5;
struct customerAccount{
string name;
string addressStreet;
string addressZip;
int phoneNum;
float accountBal;
string dateMonth, dateDay,dateYear;
};
int main()
{
customerAccount person[customer];
int x = 0;
int accountNumbers =0;
while(x!=9)
{
cout << "Input a User: " << setw(4) << "Press 1" << endl;
cout << "Edit a User: " << setw(4) << "Press 2" << endl;
cout << "Quit the Program: " << setw(4) << "Press 9" << endl;
cin >> x;
cout << endl;
if (x==1)
{
for(int count = 0 + accountNumbers; count < customer; count++)
{
cout << "Please enter the name for account " << count +1 << endl;
cin >> person[count].name;
cout << endl;
cout << "Please enter the street address:" << endl;
cin >> person[count].addressStreet;
//getline(cin,person[count].addressStreet);
cout << endl;
cout <<"Please enter the city, state, and zip code:" << endl;
cin >> person[count].addressZip;
person[count].accountBal = 1;
cout << "Please enter the account balance:" << endl;
cin >> person[count].accountBal;
while(person[count].accountBal < 0)
{
cout << "Please enter a positive account balance:" << endl;
cin >> person[count].accountBal;
}
int y;
cout << "Press 0 to put in another user:" << endl;
cout << "Press 9 to return to menu: " << endl;
cin >> y;
accountNumbers++;
if (y==9)
break;
if (accountNumbers == customer)
{
cout << "\n\nMax account limit reached ... " << endl << "Returning to the menu" << endl << endl;
break;
}
}
}
Comments
Post a Comment