Help with the switch statement

Hello im writing a program that asks the user to input a number 1-10 and will transform it into the roman numeral of that number but it seems that its not after the user inouts the number nothing will output, can someone help me fix this?
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
#include <iostream>
#include<iomanip>

using namespace std;

int main()
{
	int choice;
	 cout << "Please enter a number between 1 through 10 and press enter" << endl;
	
		 cin >> choice;

		 switch (choice)
	 {
		 case '1': cout << " The roman numeral of 1 is I" << endl;
			 break;
		 case '2': cout << " The roman numeral of 2 is II" << endl;
			 break;
		 case '3': cout << " The roman numeral of 3 is III" << endl;
			 break;
		 case '4': cout << " The roman numeral of 4 is IV" << endl;
			 break;
		 case '5': cout << " The roman numeral of 5 is V" << endl;
			 break;
		 case '6': cout << " The roman numeral of 6 is VI" << endl;
			 break;
		 case '7': cout << " The roman numeral of 7 is VII" << endl;
			 break;
		 case '8': cout << " The roman numeral of 8 is VIII" << endl;
			 break;
		 case '9': cout << " The roman numeral of 9 is IX" << endl;
			 break;
		 case '10': cout << " The roman numeral of 10 is X" << endl;
			 break;

	 }
	 system("PAUSE");
	 return 0;

}




Last edited on
closed account (Dy7SLyTq)
its because your testing an int against char '1'...'9' its the equivalent to choice == '1' || choice == '2' ...
What @DTSCode was saying, trying using the numbers with no ' '
closed account (Dy7SLyTq)
actually i meant more quotes!!! case '''1''': should work well. in all serious NSharbz was right. you want to test int against int
Topic archived. No new replies allowed.