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
_____ creates a border or space that separates information.
KATRIN_1 [288]
A. Padding
*************
7 0
2 years ago
What is the job of a bootloader?
VladimirAG [237]

Answer:

A bootloader, also known as a boot program or bootstrap loader, is a special operating system software that loads into the working memory of a computer after start-up.

Explanation:

6 0
2 years ago
Read 2 more answers
someone who protects valuable online information, like phone numbers and passwords would be considered​
charle [14.2K]

Answer: i believe a digital citizen

i am not 100% sure about that answer but i reaserached a little and thats what i found :)

I hope this helps u out a little a thank and a brainlist would be greatly appreciatecd :)

6 0
3 years ago
Which of the following describes a decision support system (DSS)?
levacccp [35]

Answer:

B.

Explanation:

8 0
2 years ago
Read 2 more answers
What are the three primary components of an Inbox?
Phantasy [73]
Three Primary Components of an Inbox:( 8 Components of an effective Email.).

Answer: 

1: From Label

2: Subject Line

3: Pre- Header

4: Content

5: Call to action

6: Images'

7: Social Media Buttons

8. Unsubscribe Option
3 0
3 years ago
Other questions:
  • Artists who draw images on a computer often use a stylus in conjunction with special _________ tablets, which offer extra-sensit
    15·1 answer
  • what is the restaurant with the black pom tree and yellow backround three letter name from hi guess the restaurant
    14·2 answers
  • 2) Complete the get_num_of_characters() function, which returns the number of characters in the user's string. We encourage you
    11·1 answer
  • Typohunting is registering a domain name that is similar to a trademark or domain name but that is slightly misspelled in hopes
    5·1 answer
  • This common technique, employed at the edge of a network, eliminates the need for public IP addresses on a private network while
    8·1 answer
  • Write a recursive, bool-valued function, containsVowel, that accepts a string and returns true if the string contains a vowel. A
    5·1 answer
  • How can you autohide the taskbar in Windows 10?
    8·2 answers
  • What is the purpose of a filename extension? How can you restore a file that you deleted from the hard disk?
    10·1 answer
  • In no less than two paragraphs, explain the risks and compliance requirements of moving data and services into the cloud.
    11·1 answer
  • There are several design goals in building an operating system; for example, resource utilization, timeliness, robustness and so
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!