4.2: Roman Numeral Converter Write a program that asks the user to enter a numbe
ID: 644426 • Letter: 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.
Prompts And Output Labels. Use the following prompt for input: "Enter a number (1 - 10): ". The output of the program should be of the form "The Roman numeral version of A is R" where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as VII.
can someone help me what is this in C++?
Explanation / Answer
#include
#include
int getNum()
{
int n;
do
{
printf("Enter a number(1-10):");
scanf("%d",&n);
}
while(n>10);
return n;
}
void romanDisplay(int n)
{
switch(n)
{
case 1:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as I.");
}
break;
case 2:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as II.");
}
break;
case 3:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as III.");
}
break;
case 4:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as IV.");
}
break;
case 5:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as V.");
}
break;
case 6:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as VI.");
}
break;
case 7:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as VII.");
}
break;
case 8:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as VIII.");
}
break;
case 9:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as IX.");
}
break;
case 10:
{
printf("The Roman numeral version of A is R where A is the Arabic numeral entered (1,2,3,...) andR is the all-capitals form of a Roman numeral, such as X.");
}
break;
default:
printf("Please enter number between 1 to 10");
break;
}
}
void main()
{
int n;
n=getNum();
romanDisplay(n);
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.