The program works fine with numbers 1-9, but when I put in 10 it will print out a "I" when it should print out the default.
#include <iostream>
using namespace std;
int main()
{
char number;
cout << "Enter a number from 1 to 5: ";
cin >> number;
switch (number)
{
case '1': cout << "The Roman numeral equivalent is: I" << endl;
break;
case '2': cout << "The Roman numeral equivalent is: II" << endl;
break;
case '3': cout << "The Roman numeral equivalent is: III" << endl;
break;
case '4': cout << "The Roman numeral equivalent is: IV" << endl;
break;
case '5': cout << "The Roman numeral equivalent is: V" << endl;
break;
default: cout << "The number must be in the range of 1 through 5 inclusive." << endl;
}
#include <iostream>
int main()
{
int number;
std::cout << "Enter a number from 1 to 5: ";
std::cin >> number;
switch(number)
{
case 1:
std::cout << "The Roman numeral equivalent is: I" << std::endl;
break;
case 2:
std::cout << "The Roman numeral equivalent is: II" << std::endl;
break;
case 3:
std::cout << "The Roman numeral equivalent is: III" << std::endl;
break;
case 4:
std::cout << "The Roman numeral equivalent is: IV" << std::endl;
break;
case 5:
std::cout << "The Roman numeral equivalent is: V" << std::endl;
break;
default:
std::cout << "The number must be in the range of 1 through 5 inclusive." << std::endl;
}
}