Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4.1: Roman Numeral Converter Write a program that asks the user to enter a numbe

ID: 3794157 • Letter: 4

Question

4.1: 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. Prompts And Output Labels. Use the following prompt for input: "Enter a number in the range of 1 - 10: ". The output of the program should be just a Roman numeral, such as VII. CLASS NAMES. Your program class should be called RomanNumerals

Explanation / Answer

#include<iostream>

using namespace std;

int main()
{
int number;

cout << " +++++++++++++++++++++++++++++++++ "
<< "   Roman Numeral Converter "
<< "++++++++++++++++++++++++++++++++++ ";

cout << "Enter a number (1-10): ";
cin >> number;

if(number < 1 || number > 10)
cout << "The number cannot be less than 1 or greater than 10!! ";
else{
switch(number)
{
case 1: cout << "The Roman numeral is: I ";
break;
case 2: cout << "The Roman numeral is: II ";
      break;
case 3: cout << "The Roman numeral is: III ";
break;
case 4: cout << "The Roman numeral is: IV ";
break;
case 5: cout << "The Roman numeral is: V ";
break;
case 6: cout << "The Roman numeral is: VI ";
break;
case 7: cout << "The Roman numeral is: VII ";
break;
case 8: cout << "The Roman numeral is: VIII ";
      break;
case 9: cout << "The Roman numeral is: IX ";
break;
case 10: cout << "The Roman numeral is: X ";
break;
default: cout << "You must enter a number between 1 - 10!! ";
} //switch ends
} //else ends

//system("pause");

return 0;
}

output:

+++++++++++++++++++++++++++++++++
   Roman Numeral Converter
++++++++++++++++++++++++++++++++++
Enter a number (1-10): The number cannot be less than 1 or greater than 10!!


I

II

III

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote