1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Advocard [28]
3 years ago
13

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 Rom

an numeral version of that number. Input Validation: Do not accept a number less than 1 or greater than 10.
Computers and Technology
1 answer:
Studentka2010 [4]3 years ago
7 0

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

You might be interested in
When molten igneous material intrudes into rock _____ metamorphism can occur.
Gnom [1K]
B) Contact metamorphism can occur.
8 0
3 years ago
The option to publish a file as a blog post is located in the____options on the File tab.
shtirl [24]
The answer is #2: Share
3 0
3 years ago
What role/service is windows 2012 server backup part of?
seraphim [82]
The answer is (D) windows server essentials experience


When Windows server Essentials Experience Role available in Windows Server 2012 R2 Standard and Datacenter is installed, you can take advantage of the many features available in Windows Server 2012 R2 Essentials. This service enables you to protect your client and server by backing up all the client computers and your server within the network.


6 0
3 years ago
What will happen to the tools and equipment, if it is not store propely?​
nikklg [1K]
This question doesn’t make any sense I guess it will rust
8 0
3 years ago
Create a for-loop which simplifies the following code segment: penUp(); moveTo(100,120); turnTo(180); penDown(); moveForward(25)
kvasek [131]

Answer:

for(var i=0; i<3; i++) {

  penUp();

  moveTo(100,120);

  turnTo(180);

  penDown();

  moveForward(25);

}

Explanation:

The i variable is the loop dummy. The code block will be executed 3 times.

7 0
3 years ago
Other questions:
  • According to the author. Consider diverse and various domains of programming languages and applications.
    14·1 answer
  • must understand both art and engineering. a. industrial designer b. environmental designer c. interior designer d. graphic desig
    14·1 answer
  • Rachel completed typing an official docment with a word processing program. She wants to make sure that her document has no typo
    15·2 answers
  • What does a linear bus topology used to connect all network devices?
    8·1 answer
  • Write a program that asks the user to enter the amount s/he has budgeted for a month. The amount should be between 1000 and 2000
    11·1 answer
  • It would be system unit on this test
    7·1 answer
  • Which of the following are some of the ways that the media influences consumers behavior
    9·1 answer
  • Define Based Assessment ​
    5·1 answer
  • What are the advantages of customer relationship managment​
    10·1 answer
  • X274: Recursion Programming Exercise: Cannonballs Spherical objects, such as cannonballs, can be stacked to form a pyramid with
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!