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
stellarik [79]
3 years ago
9

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. SAMPLE RUN #1: ./Test
Computers and Technology
1 answer:
Reptile [31]3 years ago
4 0

Answer:

The solution code is written in Java

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main (String [] args) {
  4.        Scanner inStream = new Scanner(System.in);
  5.        System.out.print("Please input a number (1 - 10): ");
  6.        int num = inStream.nextInt();
  7.        if(num < 1 || num > 10){
  8.            System.out.println("The input must be between 1 - 10");
  9.        }else{
  10.            switch(num){
  11.                case 1:
  12.                    System.out.println("I");
  13.                    break;
  14.                case 2:
  15.                    System.out.println("II");
  16.                    break;
  17.                case 3:
  18.                    System.out.println("III");
  19.                    break;
  20.                case 4:
  21.                    System.out.println("IV");
  22.                    break;
  23.                case 5:
  24.                    System.out.println("V");
  25.                    break;
  26.                case 6:
  27.                    System.out.println("VI");
  28.                    break;
  29.                case 7:
  30.                    System.out.println("VII");
  31.                    break;
  32.                case 8:
  33.                    System.out.println("VIII");
  34.                    break;
  35.                case 9:
  36.                    System.out.println("IX");
  37.                    break;
  38.                case 10:
  39.                    System.out.println("X");
  40.                    break;
  41.            }
  42.        }
  43.    }
  44. }

Explanation:

The first part of this program (Line 6 - 8) is to get input number from user using Scanner object. Input validation has been done to check if the input number is in the acceptable range (Line 10). If not, an error message will be displayed (Line 11).

If the input number is in the range of 1 - 10, the number will go through a series of switch statements checking. If the number meet the condition in one of the switch cases, it will print the corresponding roman numeral specified in the case block (Line 13 - 44). For example, if input number is 9, the case 9 condition is met and "IX" will be printed.

You might be interested in
The four general functions of any application program are: data storage, data access logic, application logic and presentation l
miv72 [106K]

Answer:

True is the correct answer to the above question.

Explanation:

  • An application program is used for specific tasks. It is a program with some specified lines of instruction which instruct the computer to process any task.
  • When a user wants to create an application program or project then he can do it with the help of four parts. which are as follows:-
  1. There needs some presentation which can be called as front-end, which is the graphics interface for the user of that program. It facilities the user to drag and drop options for the user of the project.
  2. The second thing is data storage, which is used to store the data of the project.
  3. The third thing is data access logic, which is used to create a logic to extract or add the data to the database.
  4. The fourth thing is application logic which is used to send the data or present the data to the user in front-end design.
  • The above question-statement also wants to states the same which is described above. Hence true is the correct answer to the above question.

5 0
3 years ago
. Which of the following is the correct syntax for a method header with parameters? a. public static void example(x, y) { b. pub
mojhsa [17]

Answer:

e.

public static void example(int x, in y)

Explanation:

The header comprises the access modifiers (public static), return type (void), method name (example), and parameters with the type of variable before the name of the parameters (int a, int b).

4 0
3 years ago
An example of cooler red is
BARSIC [14]

apple, stop sign, fire truck, stop light... ect

6 0
3 years ago
9. The monumental failure of Atari's E.T Extra-terrestrial was, among other things, due to the fact that ______________
nlexa [21]

Answer:

c

Explanation:

5 0
3 years ago
What is the binary conversion of 179.187.223.21?
Lemur [1.5K]

Explanation:

I hope its the correct answer i'm not sure!

6 0
3 years ago
Read 2 more answers
Other questions:
  • Being technologically literate requires being able to ______.
    11·2 answers
  • The domain in an email message tells you what?
    11·1 answer
  • When doing career research online, you always want to make sure you are viewing a reliable source, what factors about the websit
    10·2 answers
  • Selling R frog for 50 r-obux on r-oblox!!! dont answer if u not gonna buy it
    15·2 answers
  • In this program we are going to practice using the Math class by computing some important values on the unit circle. Using the a
    5·1 answer
  • What is the difference of using Selection Tool and Direct Selection Tool?
    6·1 answer
  • bro i got banned for posting an amazing bulk pic, but this dude literally posted an inappropriate, dafuq is wrong with this bann
    8·2 answers
  • what is the arrangement of various flash elements, such as the tools panel, control panel, property inspector and stage
    12·1 answer
  • Moving images of real event​
    12·2 answers
  • What is a major advantage of medical simulators?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!