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
When superiors providedirections to their subordinates regarding what to do, thisis
cluponka [151]

Answer:

Downward

Explanation:

<u>Downward communication</u>

When instructions/orders given from Superiors to Subordinates.The instruction can be via mail,oral or handbooks it can be of any form. Examples are shareholders instructing management,teacher ordering students to bring notebooks etc.  

<u>Upward communication</u>

When Information is sent bottom level to the upper levels in an organization.The information includes reports,judgments, estimations, propositions, complaints, appeals, etc  

<u>Lateral communication/Horizontal communication</u>

When same hierarchical levels shares idea or information with each other for coordinating, fulfilling a common purpose or goal.It doesn't involve sharing information with up or down levels in organization.

<u></u>

<u></u>

5 0
3 years ago
I NEED SOME MAJOR HELP W/ THIS!!! PLSSS. WHOEVER HELPS GETS 80 POINTS!!! I NEED IT DONE SOON! TYY &lt;3;)
Oksanka [162]

Answer:

I probably won't awnser them all but I'll try my best

Explanation:

Hacking is a breach of privacy online usually caused by some kind of malware injected into your device there's multiple types of this program or files malware which simply damages and harms your device. A Trojan horse is a program which tricks you by selling you a fake product which has code in it which has code which gives the hacker remote access to your device this program is usually free and masked like a crack or patch of a certain program. U got the second an third question with this one so u can just divide it into pieces. Piracy is Hacking but this time the hacker is stealing ur information through the malware. Invasion of privacy can have multiple forms online and offline. Online intrusion is when a service gives out information you entrust to it while off line Intrusion is stalking trespassing blackmail etc.

4 0
3 years ago
Explain how applying different network topologies could have an impact on the security of a network
nika2105 [10]

Answer:

More open

Explanation:

Hackers could get in easier

4 0
3 years ago
Circular errors are caused by adding the cell name of _______ cell to its own formula.
Sati [7]

Circular errors are caused by adding the cell name of the active cell to its own formula.

8 0
3 years ago
Jack is assisting his younger sibling Mary with her mathematics assignment, which includes a study of the number system. Jack ex
Elza [17]

Answer:

The answer is A). Integers

Explanation:

Booleans and Strings don't represent numbers (in most cases) so they can be eliminated.

Floats are used for representing decimals while integers are used for whole numbers.

4 0
3 years ago
Read 2 more answers
Other questions:
  • Your company runs a commercial website that enables your business partners to purchase products and manage their accounts. You w
    9·1 answer
  • On a Linux system, which command allows you to modify settings used by the built-in packet filtering firewall?
    15·1 answer
  • If your computer has a ________, someone else can gain access to it undetected.
    10·1 answer
  • How many bits long is a autonomous system number?
    13·1 answer
  • you crossed two heterozygous red flowers (dominant color), what are your chances to have a white flower
    11·1 answer
  • Name of the electrical tool and their classification
    10·1 answer
  • I need help with this question!
    11·1 answer
  • Explain the working principal of computer system with suitable diagarm​
    9·1 answer
  • Write a code snippet Now write your own code snippet that asks the user to enter two numbers of integer type (one at a time) and
    8·1 answer
  • Which option is designed by software engineers?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!