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 is the purpose of a register in a CPU? Describe three types of registers.
Ganezh [65]

Answer:

I hope this answer is correct

Explanation:

Internal registers include the instruction register (IR), memory buffer register (MBR), memory data register (MDR), and memory address register (MAR). The instruction register fetches instructions from the program counter (PC) and holds each instruction as it is executed by the processor.

5 0
3 years ago
Assume you have a packet with data payload of 1024 bytes. The packet header is 6 bytes. Assume there is no other overhead. The c
Sveta_85 [38]

Answer:

PER= 0.824

Explanation:

Total bytes = 1024+6

=1030 bytes

=1030*8 bits

= 8240 bits

BER = 0.0001

Packet Level Error (PER) = 8240*0.0001

= 0.824

7 0
3 years ago
A web browser sends a request to the web server using what
goldenfox [79]
Web browsers and servers communicate via TCP/IP.  HTTP protocol is the standard application protocol that supports the responses.
3 0
3 years ago
How is an image represented
Sonja [21]
With a sertain address.
4 0
3 years ago
Read 2 more answers
Subtract 01101011-00101010
White raven [17]

Answer:

Alexa says minus 8

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • If you wish to maintain a consistent style to all the documents you create, it would be helpful to use a _____.
    10·1 answer
  • Which folder(s) are commonly used in the Navigation Pane of Outlook? Check all that apply.
    13·1 answer
  • If you can't get the keys away from a drunk friend, it is better to call the police than to let them drive drunk. A. True B. Fal
    10·1 answer
  • What does the merge &amp; center button in the alignment group on the home tab do?
    8·1 answer
  • Unemployment can be viewed as
    14·1 answer
  • - What are the different types of clients?
    12·1 answer
  • Write an algorithm to find perimeter of circle<br>​
    12·1 answer
  • I can't solve this <br> Python loop with while statement
    15·2 answers
  • What are five types of applications you can create in Visual Basic 2017?
    12·2 answers
  • What does it mean when your phone says not registered on network?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!