/* Roman Numeral Converter - This program asks the user to enter a number within
the range of 1 through 10. It uses a switch statement to display the Roman
numeral version of that number. */
#include "Utility.h"
int main()
{
/* Hold roman numerals */
string numberOne = "I",
numberTwo = "II",
numberThree = "III",
numberFour = "IV",
numberFive = "V",
numberSix = "VI",
numberSeven = "VII",
numberEight = "VIII",
numberNine = "IX",
numberTen = "X";
/* Hold a numeral */
int numeral;
/* Ask the user for a number */
cout << "\t\tWelcome to the Roman Numeral Converter!\n\n"
<< "Enter a number within the range of 1 through 10 and i will\n"
<< "convert it to a roman numeral: ";
cin >> numeral;
/* Display roman numerals if input is valid */
switch (numeral)
{
case 1: cout << "\nnumber 1 in roman numeral form is " << numberOne << endl;
break;
case 2: cout << "number 2 in roman numeral form is " << numberTwo << endl;
break;
case 3: cout << "number 3 in roman numeral form is " << numberThree << endl;
break;
case 4: cout << "number 4 in roman numeral form is " << numberFour << endl;
break;
case 5: cout << "number 5 in roman numeral form is " << numberFive << endl;
break;
case 6: cout << "number 6 in roman numeral form is " << numberSix << endl;
break;
case 7: cout << "number 7 in roman numeral form is " << numberSeven << endl;
break;
case 8: cout << "number 8 in roman numeral form is " << numberEight << endl;
break;
case 9: cout << "number 9 in roman numeral form is " << numberNine << endl;
break;
case 10: cout << "number 10 in roman numeral form is " << numberTen << endl;
break;
default: cout << "Invalid number! Valid numbers are 1 through 10.\n";
break;
}
pauseSystem();
return 0;
}
Thursday, November 17, 2016
Programming Challenge 4.2 - Roman Numeral Converter
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment