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
What natural resources products are discussed in the article? Are they renewable or nonrenewable?
Alex

Where is the article

4 0
3 years ago
Read 2 more answers
CAPTCHAs can be used as a form of signature to create a valid contract in e-commerce. True False
Len [333]
Thank you for posting your question here at brainly. I hope the answer will help you. Feel free to ask more questions.
The statement "CAPTCHAs can be used as a form of signature to create a valid contract in e-commerce. " is true. It is <span>a program or system intended to distinguish human from machine input, typically as a way of thwarting spam and automated extraction of data from websites.</span>
4 0
3 years ago
Read 2 more answers
Add me on Pokemon go, my trainer code is 5584 3300 5313
evablogger [386]

Answer:

no want it

Explanation:

7 0
3 years ago
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Wri
Aneli [31]

Answer:

The code is mentioned below.

Explanation:

This code is written in C.

Assuming that an array of 6 by 8 is already initialized and stored in a vector

x[6][8]

which will be called or referred in program by:

x [i] [j]

Alongwith the array the variables i j and max will be initialized as integers.

CODE:

int i,j,max;

max=0;

for(i=0;i<6;i++)

{

for(j=0;j<6;j++)

{

if(max>x[i][j])

max = x[i][j];

}

}

This code will check each and every entry of 6 by 8 array and place the largest value in max.

5 0
3 years ago
Which of the following is a way to sell the network proposal to management?Group of answer choicestalk about upgrades from 10Mbp
Assoli18 [71]
Ethernet is the best in reliability and speed
5 0
3 years ago
Other questions:
  • The most popular input device of a computer is a(n) ____.
    6·1 answer
  • URGENT!!!
    13·2 answers
  • For window 7 explain the steps you will use to find the available program you will list.
    13·1 answer
  • Tower Building Activity
    12·1 answer
  • computer has a 32-bit instruction word broken into fields as follows: opcode, six bits; two register file address fields, five b
    11·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • Tricking someone to reveal personal information, passwords, and other information that can compromise a security system is known
    13·1 answer
  • Which US electronics company was the pioneer in home video game consoles
    10·1 answer
  • . When a function template has two parameterized types, one as the return value, and one as an argument, then _____.
    11·1 answer
  • Edhesive 9.10 Question 3
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!