help asap please!

i cant figure out why this program keeps looping infinitly when i run it and try to put some input, please help!


#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>


using namespace std;

struct Account
{
string name;
char street, city,state;
int addNum, zip,telNum,dateLp;
double bal;

};

int main()
{
int option;
Account account[20];
int addCount=0;
string namePers[20];

cout << "Customer Account Database\n";
do
{
cout << "please choose an option:" << endl;
cout << "1.Add account" << endl << "2.Edit account" << endl << "3.Display account" << endl << "4.Exit program" << endl;//makes a selection
cout << "Option number: ";
cin >> option;
if ((option >= 1) && (option <= 4)) //insures the selected value is valid
{
if (option == 1)
{
if (addCount < 10)
{
cout << "Add an account: " << endl << "current account number is #" << (addCount + 1) << "(save this number for reference)" << endl;
cout << "1.Name: ";
getline(cin, account[addCount].name);
cout << "2.Address(format:numbers[ENTER] street name[enter]): ";
cin >> account[addCount].addNum;
cin>> account[addCount].street;
cout << "3.City, State, Zipcode(format:City[ENTER] State[ENTER]Zipcode[ENTER]): ";
cin >> account[addCount].city >> account[addCount].state >> account[addCount].zip;
cout << "4.Phone number(no spaces or non number digits): ";
cin >> account[addCount].telNum;
cout << "5.Current Account Balance(to the nearest cent): ";
cin >> account[addCount].bal;
cout << "6.Date of last payment(in MMDDYYYY format): ";
cin >> account[addCount].dateLp;

cout << endl << "*****Account Saved*****" << endl << endl;
}
else
{
cout << "You have reached the maximum number of accounts allowed."<<endl;
}
}

else if (option == 2)
{
int editNum = 0;
int editOpt = 0;
cout << "Edit an account:" << endl << "Please state the account # you would like to edit: ";
cin >> editOpt;//this is the choice of account to edit

cout << "What would you like to edit: " << endl << "1.Name" << endl << "2.Address" << endl << "3.City,State,Zipcode" << endl
<< "4.Phone number" << endl << "5.Current account Balance" << "6.Date of last payment" << endl;
cin >> editNum;//this is which peice of information will be edited

if (editNum == 1)
{
cout << "1.Name: ";
getline(cin, account[editOpt].name);
}
if (editNum == 2)
{
cout << "2.Address(format:numbers[ENTER] street name[enter]): ";
cin >> account[editOpt].addNum >> account[editOpt].street;
}
if (editNum == 3)
{
cout << "3.City, State, Zipcode(format:City[ENTER] State[ENTER]Zipcode[ENTER]): ";
cin >> account[editOpt].city >> account[editOpt].state >> account[editOpt].zip;
}
if (editNum == 4)
{
cout << "4.Phone number(no spaces or non number digits): ";
cin >> account[editOpt].telNum;
}
if (editNum == 5)
{
cout << "5.Current Account Balance(to the nearest cent): ";
cin >> account[editOpt].bal;

}
if (editNum == 6)
{
cout << "6.Date of last payment(in MMDDYYYY format): ";
cin >> account[editOpt].dateLp;
}
exit(0);
}
else if (option == 3)
{
int disNum;
cout << "Display an account" << endl << "Please select the account number you would like to view: ";
cin >> disNum;

cout << "1.Name: " << account[disNum].name;
cout << "2.Address(format:numbers[ENTER] street name[enter]): " << account[disNum].addNum << account[disNum].street<<endl;
cout << "3.City, State, Zipcode(format:City[ENTER] State[ENTER]Zipcode[ENTER]): " << account[disNum].city << account[disNum].state << account[disNum].zip<<endl;
cout << "4.Phone number(no spaces or non number digits): " << account[disNum].telNum<<endl;
cout << "5.Current Account Balance(to the nearest cent): "<< account[disNum].bal<<endl;
cout << "6.Date of last payment(in MMDDYYYY format): " << account[disNum].dateLp << endl;


exit(0);
}
else if (option == 4)// else will end the cycle and close the program
exit(0);
}
} while (option != 4);
return 0;
}
closed account (j3Rz8vqX)
When does it run indefinitely? I'm pretty sure if you entered 4 as the input, it would immediately end.

Can you reproduce the error? If so, what was the last thing you did/entered?

My assumption is that you've entered incorrect data at specific prompts.

Possible errors:
char street, city,state; These can only take one character.

int addNum, zip,telNum,dateLp; These can only be whole numbers of max integer size; no '-' for telephone number, or '/' for date.
Topic archived. No new replies allowed.