//Zachary Abdollahi CS1A Chapter 4, P. 220, #2
//
/*******************************************************************************
*
* CONVERT NUMBERS TO ROMAN NUMERALS
*
*______________________________________________________________________________
* This program asks the user to enter a number from 1 to 10 and uses a switch
* statement to display the Roman numeral version of that number. Input is
* validated so numbers less than 1 or greater than 10 are not accepted.
*
* INPUT
* number : Number entered by user (1-10)
*
* OUTPUT
* Roman numeral equivalent of number, printed to screen
*
******************************************************************************/
#include <iostream>
using namespace std;
int main()
{
int number; //INPUT - Number entered by user (1-10)
// Get input from the user, with validation
cout << "Enter a number from 1 to 10: ";
cin >> number;
while (number < 1 || number > 10)
{
cout << "Invalid number. Please enter a number from 1 to 10: ";
cin >> number;
}
// Use a switch statement to display the Roman numeral
switch (number)
{
case 1:
cout << "The Roman numeral is I " << endl;
break;
case 2:
cout << "The Roman numeral is II" << endl;
break;
case 3:
cout << "The Roman numeral is III" << endl;
break;
case 4:
cout << "The Roman numeral is IV" << endl;
break;
case 5:
cout << "The Roman numeral is V" << endl;
break;
case 6:
cout << "The Roman numeral is VI" << endl;
break;
case 7:
cout << "The Roman numeral is VII" << endl;
break;
case 8:
cout << "The Roman numeral is VIII" << endl;
break;
case 9:
cout << "The Roman numeral is IX" << endl;
break;
case 10:
cout << "The Roman numeral is X" << endl;
break;
}
return 0;
}