I am currently writing a project for college C++, and this week I am supposed to ask a customer using my application for their name, phone number, and other information. When I start creating variables (shown below), I start running into issues.
int main()
{
string customername;
cout << "Enter your first and last name: ";
cin >> customername;
int phonenumber;
cout << "Enter your phone number with no spaces";
cin >> phonenumber;
string address;
cout << "Enter your address";
cin >> address;
int creditcard;
cout << "Enter your credit card number";
cin >> creditcard;
string expdate;
cout << "Enter your card expiration date as month/year";
cin >> expdate;
int cid;
cout << "Enter your CID";
cin >> cid;
cout << customername;
cout << phonenumber;
cout << address;
cout << creditcard;
cout << expdate;
cout << cid;
return 0;
}
I ask the user for their name first, and on a hunch after I was done writing this part I had the system output all of the data it had stored under these variables. First of all, the program only asks me the first question - after that, it skips everything else completely and just outputs it at the end. Second, when it does output the customer name, it only outputs their first name. I'm totally lost, if anyone could help I'd really appreciate it.
and then after the above issue, if you go back to the original code in the original post, the program does not ask me for any of those outputs at all, it just blows through them and finishes.
got it ok, thanks - now i'm trying to ask for their address - I have this:
<code>
string addpt1, addpt2, addpt3, addpt4, addpt5, addpt6, addpt7;
cout << "Enter your full address with no punctuation:" << endl;
cin >> addpt1 >> addpt2 >> addpt3 >> addpt4 >> addpt5 >> addpt6 >> addpt7;
</code>
this works if their address has seven parts (ie 123 north south court denver colorado 80018), but if the address has any more or any less parts than 7 it doesn't work - how would I make this so that it can handle any address?