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]
2 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]2 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 you divide a picture into thirds, how many parts do you end up with? *
lara31 [8.8K]

Answer:

3

Explanation:

6 0
3 years ago
Read 2 more answers
POINT AND BRAINLIEIST GIVE AWAY!!!
Sonbull [250]

Answer:

Hey whats up

Explanation:

Count me in chief! I love when fellow user give out mighty points

7 0
3 years ago
Read 2 more answers
describe how sodium ammonium chloride can be separated from a solid mixture of ammonium chloride and anhydrous calcium chloride​
kirill115 [55]

Answer:

There are way in separating mixtures of chlorides salts such as that of sodium chloride and ammonium chloride. It can be done by crystallization, filtration or sublimation. If we want to separate the mixture, we have to heat up to 330-350 degrees Celsius and collect the gas that will be produced.

5 0
3 years ago
What do you like most about brainly?
Natali5045456 [20]

Getting the answers to my homework :p

4 0
3 years ago
Read 2 more answers
What classes should I take in high-school for majoring in computer science?
Gala2k [10]

Answer:

Computer science are the disciplines that study information, computing and the applications or ecosystems where they are developed. It is a science that comes from applied mathematics and has 3 branches that are quite well known. On the one hand we have software engineering, secondly theory as such (primary study of algorithms and data, etc.) and finally the application of the amalgam of the first two, which end up resulting in disciplines such as big data, cybersecurity or computer security, machine learning, artificial intelligence, etc. However, we are talking about a very broad science with various branches of work. Technological advances that have improved the scope of education, now allow us to develop in specific skills and computer science is one of the macro careers that have benefited the most thanks to the diversity of subjects it encompasses. This is where the on-demand courses available on the edX platform come in. Computer scientists are in one of the best times for their career advancement. We invite you to be part of the technological development and information and computing technologies through online courses.

Explanation:

6 0
2 years ago
Other questions:
  • Themes are applied from which tab?
    6·1 answer
  • What program controls the hardware and software in a computer?
    10·1 answer
  • What should you remember when using the thesaurus to replace words?
    8·2 answers
  • A network security analyst received an alert about a potential malware threat on a user’s computer. What can the analyst review
    12·1 answer
  • Loops are frequently used to ____; that is, to make sure it is meaningful and useful.
    12·1 answer
  • When using color in a computer - generated presentation aids you should use?
    7·1 answer
  • Always follow the routine "clean up while in use and clean up before keeping it".
    6·1 answer
  • Which input and output pair is correct for a bicycle?
    12·1 answer
  • 2. Explain the difference between a JMP instruction and CALL instruction
    6·1 answer
  • What safety do you need to have ready to start a device repair?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!