/*Write a program that asks the user to enter a number within the range of 1 through
10. Use a switch statement to display the Roman numberal version of that number.*/
#include "stdafx.h"
#include <iostream>
usingnamespace std;
int main()
{
int x;
cout << "Enter a number between 1 and 10: " << endl;
cin >> x;
while(x <= 0 || x > 10)
{
cout << "Please enter a number between 1 and 10" << endl;
cin >> x;
}
switch (x)
{
case'1': cout << "The Roman numeral version is: I" << endl;
break;
case'2': cout << "The Roman numeral version is: II" << endl;
break;
case'3': cout << "The Roman numeral version is: III" << endl;
break;
case'4': cout << "The Roman numeral version is: IV" << endl;
break;
case'5': cout << "The Roman numeral version is: V" << endl;
break;
case'6': cout << "The Roman numeral version is: VI" << endl;
break;
case'7': cout << "The Roman numeral version is: VII" << endl;
break;
case'8': cout << "The Roman numeral version is: VIII"<< endl;
break;
case'9': cout << "The Roman numeral version is: IX" << endl;
break;
case'10':cout << "The Roman numeral version is: X" << endl;
}
return 0;
}
When I execute this program the result does not display a roman numeral but rather says press any key to continue, as if it skipped the switch statement altogether! I can't find any syntax problem or anything so please, help me!
Please, show me how to get 10 in a single char.
Only his problem was quotation marks around values. That it, nothing else have to change. http://cpp.sh/3bm http://ideone.com/4q9WJb