this is a pretty simple program but I'm missing something. I was asked to choose variables that would be the most efficient means to store data and then after the user enters this info I am to use cout to display it. But for some reason it skips past the last cin statement and doesn't allow me to enter a char variable. I have tried using cin.ignore() before the prompt on the last question but with no luck. Here is the code:
using namespace std;
int main()
{
unsigned int population;
float avg_income, hourly_wage;
unsigned short int students, gnp_florida;
char gender;
// Instructions for all answers
cout << "For all answers don't type a comma(,). For example the number 4,598,453.00 should be listed";
cout << " as 4598453.00\n";
// Get user input and assign it to the variables
cout << "What is the population of the US?: ";
cin >> population;
cout << "What is the average family income in the US?: ";
cin >> avg_income;
cout << "Give the hourly wage of 1 family member: ";
cin >> hourly_wage;
cout << "Enter the total number of students attending SPC: ";
cin >> students;
cout << "What is the total GNP of Florida?: ";
cin >> gnp_florida;
cout << "Enter a gender (M for male or F for female): ";
cin >> gender;
// Display the variable's values using cout
cout << "These are your answers......\n ";
cout << "The total US population is " << population << endl;
cout << "The average family income in the US is " << avg_income << endl;
cout << "The hourly wage of 1 person in a household is " << hourly_wage << endl;
cout << "The number of students attending SPC is " << students << endl;
cout << "The GNP for Florida is " << gnp_florida << endl;
cout << "The gender you entered is " << gender << endl;
// Make the program beep 5 times using escape sequences
cout << "\a\a\a\a\a";
system("pause");
return 0;
}
This is what my output looks like:
For all answers don't type a comma(,). For example the number 4,598,453.00 should be listed as 4598453.00
What is the population of the US?: 300000000
What is the average family income in the US?: 53453.24
Give the hourly wage of 1 family member: 15.35
Enter the total number of students attending SPC: 30253
What is the total GNP of Florida?: 753896.45
Enter a gender (M for male or F for female): These are your answers......
The total US population is 300000000
The average family income in the US is 53453.2
The hourly wage of 1 person in a household is 15.35
The number of students attending SPC is 30253
The GNP for Florida is 52428
The gender you entered is ╠
Press any key to continue . . .
Please explain what's going on and thank you in advance for your help