Need assistance on printing out a cout statement using stored variables.

Im trying to run my program and it works fine until the very end where I want it to read "<name> is a <gender> citizen of <nation>." with the corresponding variables. Here is my work for the time being. Also is there a way to make it where if someone puts a M or m for gender, it will spit out Male instead of just m or M.
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
using namespace std;

int main() 

{
 char gender;
 string name;
 char x, nation;
 cout << "M and m for Male\n";
 cout << "F and f for Female\n";
 cout << "What is your gender\n";
 cin >> gender;
 if ((gender == 'm') || (gender == 'M'))
 {
 	cout << "What is his name.\n";
 	cin >> name;
 } 
 else if ((gender == 'f') || (gender == 'F'))
 {    
    cout << "What is her name.\n";
    cin >> name;
 }
    cout << "U - United States \n";
    cout << "K - United Kingdom \n";
    cout << "C - Canada \n";
    cout << "M - Mexico \n";
    cout << "S - Spain \n";
    cout << "H - China \n";
    cout << "J - Japan \n";
    cout << "Any other codes - Unknown \n";
	cout << "What is your nationality? \n";
	cin >> x;
	switch (x)
	{
		case 'U':
		case 'u':
			cout << "United States \n";
			cin >> nation;
			break;
		case 'K':
		case 'k':
		    cout << "United Kingdom \n";
		    cin >> nation;
		    break;
		case 'C':
		case 'c':
		    cout << "Canada \n";
		    cin >> nation;
		    break;
		case 'M':
		case 'm':
		    cout << "Mexico \n";
		    cin >> nation;
		    break;
		case 'S':
		case 's':
		    cout << "Spain \n";
		    cin >> nation;
		    break;
		case 'H':
		case 'h':
		    cout << "China \n";
		    cin >> nation;
		    break;
		case 'J':
		case 'j':
		    cout << "Japan \n";
		    cin >> nation;
		    break;
		default:
		    cout << "Unknown\n";    
	}
	cout << name <<" is a " << gender << " citizen of " << nation << " . ";
}

Last edited on
this tutorial could be helpful http://www.hellgeeks.com/switch-statement/
you use something confusing logic.
what is for nation variable?
should it store name of nation like : japan or spain?
Topic archived. No new replies allowed.