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
Text that is heavier or darker than other text in the document is considered _____.
kvv77 [185]

The text that is heavier or darker than other text in a document is considered  Bold.

Hope this helped!~

7 0
3 years ago
Read 2 more answers
Font size, font style, and _______ are all aspects of character formatting.
mel-nik [20]
The answer, im prettysure, is d. typeface.
hope this helps (:

6 0
3 years ago
Read 2 more answers
Your manager has asked you to write a program that displays the percentage of males and female in your class. The program should
Blababa [14]

<u>Explanation:</u>

The program using <em>python programming language </em>would be:

First, we write the Input prompt.

<u>Input  prompt for the user</u>

number_of_males_in_class = int (input ('Enter the number of males: '))

number_of_females_in_class = int(input('Enter the number of females: '))

Next, we write the Process algorithm.

<u>Process  algorithm</u>

total_number_of_students_in_class = number_of_females_in_class + number_of_males

_in_class

percentage_of_males_in_class = number_of_males_in_class / total_number_of_students

_in_class

percentage_of_females_in_class = number_of_females / total_number_of_students

Finally, the Output process

<u>Output process</u>

print('Total number of males in class =', format(percentage_of_males_in_class, '.0%'))

print('Total number of females =', format(percentage_of_females_in_class, '.0%'))

7 0
3 years ago
Which of the following best describes compounds.
Lemur [1.5K]
A. They can only be separate chemically
4 0
3 years ago
Nnbnnb dfhhfhfbhfbhdffd<br> ddbhfbhdhfbhdhf<br> hhffudjbfbjkd<br> dbhdfbhbfhdb
saveliy_v [14]
Tahheuend
Thatgeheh
Thahyateg
Fascinating
:)
6 0
3 years ago
Other questions:
  • What is an example of constructive criticism for an employee who is shy during meetings?
    15·2 answers
  • What is UNIX? A program for writing documents Graphical interface Internet browser Operating system
    8·2 answers
  • Windows domain policy to disable windows 10 update
    7·1 answer
  • A hub or ____ is a central point that connects several devices in a network together.
    11·1 answer
  • The desktops of computers running the same OS all look the same
    8·1 answer
  • Classes cannot:
    10·1 answer
  • Which port must be open on your router to allow you to upload device configuration and firmware updates using trivial file trans
    13·1 answer
  • Premise: Tracy has a file that contains a list of actors and the movies in which they acted. She wants to know the top 3 ranked
    8·1 answer
  • Determine which careers you can enter after completing a training program and which careers require a college degree.
    6·1 answer
  • The goal of this project is to become familiar with basic Python data processing and file usage. By the end of this project, stu
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!