/*Date: 02/11/08 Programming Fundamentals II Homework Assignment Chapter 4-Question #4.2 Roman Numeral Converter - 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 numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10. */ #include #include using namespace std; int main() { int number1;//create variable to store number bool closing = true;//creates bool variable for solution output at end of program string roman1;//creates variable to store roman numeral //introduce program and ask for input of number between 1-10 cout <<"++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; cout <<"Welcome to Hector's Roman Numeral Converter, Build 1\n"; cout <<"++++++++++++++++++++++++++++++++++++++++++++++++++++\n"; cout <<"This progam will convert any number between 1-10 to Roman Numeral.\n"; cout <<"Please enter any number between 1 and 10.\n"; cin >> number1;//store input from user in variable number1 if (number1 > 10)//if number larger than 10, notify user { cout <<"The number you entered is too large!\n"; closing = false; } if (number1 < 1)//if number less than 1, notify user { cout <<"The number you entered is too small!\n"; closing = false; } //the following lines will assign value to number1 if (number1 == 1) roman1 = "I"; if (number1 == 2) roman1 = "II"; if (number1 == 3) roman1 = "III"; if (number1 == 4) roman1 = "IV"; if (number1 == 5) roman1 = "V"; if (number1 == 6) roman1 = "VI"; if (number1 == 7) roman1 = "VII"; if (number1 == 8) roman1 = "VIII"; if (number1 == 9) roman1 = "IX"; if (number1 == 10) roman1 = "X"; //Display the roman numeral to user if (closing == true)//if number between 1-10 display following message { cout <<"Your Number is equal to the Roman Numeral " << roman1 << ".\n"; cout <<"Thank You for using my program!\n"; } else//if number not between 1-10 display following message cout <<"You did not enter a number between 1-10, please try my program again!\n"; return 0;//end program }