Need Help

I need help with my code for school. My code will not let the user input 'y' or 'n' for cin >> poBoxConfirm. I have looked over my code and it looks right to me. I cannot figure this out for the life of me.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <string>
using namespace std;

int main ()
{
	
        int poBoxNum, aptComplexNum, aptNum, houseNum, zipcode;
	string firstName, lastName, streetName, city, state, addressConfirm, poBoxConfirm, aptConfirm;
	
	//have user enter their name
	cout << "Please enter your first and last name." << endl << endl;
	cin >> firstName, lastName;
	
	//welcoming message with the users name
	cout << endl << endl << "Welcome " << firstName << ". Thank you for chosing JM Computers for your computer needs" << endl << endl;
	
	//explaining what the company sells
	cout << "Here at JM Computers we sell computer hardware and software, networking, etc." << endl << endl;
	
	//ask user if we are shipping to PO Box
	cout << "Are we shipping to a PO Box? Enter 'y' for yes or 'n' for no." << endl << endl;
	cin >> poBoxConfirm;

        return 0;
}
Last edited on
Split line 13 up.
cin >> firstName; cin >> lastName;
This is because comma is a bit of a strange operator in C++.
http://en.cppreference.com/w/cpp/language/operator_other
Awesome. Thank you very much. It works now. I would've never guessed that.
Thank you for the link as well.
Your welcome! Hope you come back to the forums again sometime :)
Topic archived. No new replies allowed.