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.

Answers

Answer 1
Answer:

Answer:

// program in C++.

// headers

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// Variable

   int num;

   cout << "Enter a number between 1 and 10: ";

   // read input

   cin >> num;

   // validate input number

   while(num<1||num>10)

   {

   // if input is wrong then print error message

       cout<<"Wrong input!!Enter again:";

       // read again

       cin>>num;

   }

   // print output

   cout << "The Roman numeral for "<<num<<" is:";

   // switch

   switch (num)

   {

       case 1:

       // if input is 1

           cout<<"I"<<endl;

           // exit the switch

           break;

       case 2:

       // if input is 2

           cout<<"II"<<endl;

           // exit the switch

           break;

       case 3:

       // if input is 3

           cout<<"III"<<endl;

           // exit the switch

           break;

       case 4:

       // if input is 4

           cout<<"IV"<<endl;

           // exit the switch

           break;

       case 5:

       // if input is 5

           cout<<"V"<<endl;

           // exit the switch

           break;

       case 6:

       // if input is 6

           cout<<"VI"<<endl;

           // exit the switch

           break;

       case 7:

       // if input is 7

           cout<<"VII"<<endl;

           // exit the switch

           break;

       case 8:

       // if input is 8

           cout<<"VIII"<<endl;

           // exit the switch

           break;

       case 9:

       // if input is 9

           cout<<"IX"<<endl;

           // exit the switch

           break;

       case 10:

       // if input is 10

           cout<<"X"<<endl;

           // exit the switch

           break;

         // default

       default:

           break;

   }

return 0;

}

Explanation:

Read a number from usr and assign it to variable "num". If the input number is less than 1 or greater than 10 then ask again to enter a number until user  enter a number between 1-10 only.Then with the help of switch() function print  the equivalent Roman number.

Output:

Enter a number between 1 and 10: -5                                                                                        

Wrong input!!Enter again:12                                                                                                

Wrong input!!Enter again:6                                                                                                

The Roman numeral for 6 is:VI


Related Questions

You can insert a new slide by pressing the _____ keyboard shortcut keys?
Identify the parts of a spreadsheet by using the drop-down menus to select the part that corresponds to the labeled diagram to the right.A B C D E
The quote, "Where you tend a rose, my lad, a thistle cannot grow," referred to --- A. Dickon teaching Colin the correct way to plant and weed the rosebushes in the secret garden B. Colin learning to think positive thoughts instead of discouraging and fearful ones C. Mrs. Sowerby telling Mrs. Craven that Colin needed sympathy, love, and attention to improve D. Ben explaining that roses ruin the soil so that other plants cannot thrive
Which of the following is a commonly used mouse command?a. Stop c. Run b. Drag d. Pull
Describe conductors and insulators in terms of energy

How to take a set of numbers and turn them into a list in python

Answers

Answer:

numbers = (0, 9, 8, 7, 5, 2, 4, 5, 3)

numList = list(numbers)

print(numList)

Explanation:

In the default setting on PowerPoint how many changes can the undo button make

Answers

The default setting of the undo command on Microsoft PowerPoint can reach from 5 to 10 times. Note that the Undo button/command is very useful as it can fix errors in just a single click of the button, and you can adjust the amount if you want more ways to undo.

The software program you need to have to read PDF file, such as the PDF files you download from your My Courses page, isa. Adobe Reader.
b. Shock Wave.
c. Applet.
d. Flash.

Answers

I always use A) Adobe Reader

Statements about the FAFSA process are TRUE?

Answers

FAFSA  is the largest source of financial aid for the students in USA.. Here are a true statement about FAFSA process : you should only fill out FAFSA form if you can demonstrate financial need, such as by showing your parent's monthly paycheck or loan bills

The annual percentage rate on a credit card determines _______. Athe amount of interest you are charged on credit card purchases Bthe amount your credit limit can go up within a year Chow many credit cards you can own DNone of the above

Answers

The answer is (a.) The amount of interest you are charged on credit card purchases

The Annual Percentage Rate or APR on your credit card is determined by the interest you made from your purchases for the whole year. APR includes other fees and additional costs.

The answer is (The amount of interest you are charged on credit card purchases .)


How do I do the exclamation mark

Answers

you hold shift while pressing 1
Hey!
All you have to do it press the shift button(left of keyboard), under caps lock. And press 1.
Shift+1=!