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
UkoKoshka [18]
3 years ago
8

java Your program class should be called RomanNumerals 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. Do not accept a number less than 1 or greater than 10. s

Engineering
2 answers:
Ann [662]3 years ago
6 0

Answer:

// Scanner class is imported to allow program

// receive input

import java.util.Scanner;

// RomanNumerals class is defined

public class RomanNumerals {

   // main method that signify beginning of program execution

   public static void main(String args[]) {

       // Scanner object scan is created

       // it receive input via keyboard

       Scanner scan = new Scanner(System.in);

       // Prompt is display asking the user to enter number

       System.out.println("Enter your number: ");

       // the user input is stored at numberOfOrder

       int number = scan.nextInt();

     

           // switch statement which takes number as argument

           // the switch statement output the correct roman numeral

           // depending on user input

          switch(number){

           case 1:

               System.out.println("I");

               break;

           case 2:

               System.out.println("II");

               break;

           case 3:

               System.out.println("III");

               break;

           case 4:

               System.out.println("IV");

               break;

           case 5:

               System.out.println("V");

               break;

           case 6:

               System.out.println("VI");

               break;

           case 7:

               System.out.println("VII");

               break;

           case 8:

               System.out.println("VIII");

               break;

           case 9:

               System.out.println("IX");

               break;

           case 10:

               System.out.println("X");

               break;

           // this part is executed if user input is not between 1 to 10

           default:

               System.out.println("Error. Number must be between 1 - 10.");

     }

   }

}

Explanation:

The program is well commented. A sample image of program output is attached.

The switch statement takes the user input (number) as argument as it goes through each case block in the switch statement and match with the corresponding case to output the roman version of that number. If the number is greater 10 or less than 1; the default block is executed and it display an error message telling the user that number must be between 1 - 10.

Iteru [2.4K]3 years ago
6 0
<h2>Answer:</h2>

//import the Scanner class to allow for user's input

import java.util.Scanner;

// Write the class header with the appropriate name

public class RomanNumerals {

   // Write the main method - this is where execution begins

   public static void main(String[] args) {

       //Create an object of the Scanner class to allow user's to enter the number

       Scanner input = new Scanner(System.in);

       

       //Prompt the user to enter a number

       System.out.println("Please enter a number within the range of 1 through 10");

       

       //Receive the number from the user and store in an int variable

       int num = input.nextInt();

       

       

       //Begin the switch statement using the num

       switch (num) {

       

           //If the number is 1

           //Print the corresponding Roman numeral -> I

           //Then break out of the switch statement

           case 1 :  

               System.out.println("I");

               break;

               

           //If the number is 2

           //Print the corresponding Roman numeral -> II

           //Then break out of the switch statement

           case 2 :

               System.out.println("II");

               break;

               

           //If the number is 3

           //Print the corresponding Roman numeral -> III

           //Then break out of the switch statement

           case 3:

               System.out.println("III");

               break;

               

           //If the number is 4

           //Print the corresponding Roman numeral -> IV

           //Then break out of the switch statement

           case 4:

               System.out.println("IV");

               break;

               

           //If the number is 5

           //Print the corresponding Roman numeral -> V

           //Then break out of the switch statement

           case 5:

               System.out.println("V");

               break;

               

           //If the number is 6

           //Print the corresponding Roman numeral -> VI

           //Then break out of the switch statement

           case 6:

               System.out.println("VI");

               break;

               

           //If the number is 7

           //Print the corresponding Roman numeral -> VII

           //Then break out of the switch statement

           case 7:

               System.out.println("VII");

               break;

             

           //If the number is 8

           //Print the corresponding Roman numeral -> VIII

           //Then break out of the switch statement

           case 8:

               System.out.println("VIII");

               break;

           

           //If the number is 9

           //Print the corresponding Roman numeral -> IX

           //Then break out of the switch statement

           case 9:

               System.out.println("IX");

               break;

               

           //If the number is 10

           //Print the corresponding Roman numeral -> X

           //Then break out of the switch statement

           case 10:

               System.out.println("X");

               break;

           

           //If the number is not within range [That is the default case]

           //Print the corresponding error message.  

           //You might want to print the error message using  

           //System.err.println() rather than

           //the regular System.out.println()

           //Then break out of the switch statement

           default:

               System.err.println("Error: The number should not be less than 1 or greater than 10");

               break;

               

       }          //End of switch statement

       

       

  }  // End of main method

   

}  // End of class declaration

=============================================================

<h2><u>Sample Output 1:</u></h2>

>> Please enter a number within the range of 1 through 10

5

>> V

<h2></h2>

==============================================================

<h2><u>Sample Output 2:</u></h2>

>> Please enter a number within the range of 1 through 10

0

>> Error: The number should not be less than 1 or greater than 10

<h2 />

===============================================================

<h2></h2><h2></h2><h2></h2><h2></h2><h2>Explanation:</h2>

The code has been written in Java and it contains comments explaining every section of the code, please go through the comments to get a better understanding of the code.

Actual codes are written in bold face to distinguish them from the comments.

You might be interested in
If you replace the text value in an associative dimension, the text value will not change when the
Nostrana [21]

Answer:

C

Explanation:

7 0
3 years ago
A disk of radius 2.1 cm has a surface charge density of 5.6 µC/m2 on its upper face. What is the magnitude of the electric field
Assoli18 [71]

Answer:

=6.3*10^3 N/C

Explanation:

solution:

from this below equation (1)

E=σ/2εo(1-\frac{z}{\sqrt{z^2-R^2} } )...........(1)

we obtain:

=5.6*10^-6 \frac{c}{m^2} /2(8.85*10^-12\frac{c^2}{N.m^2} ).(1-\frac{9.5 cm}{\sqrt{9.5^2-2.1^2} } )

=6.3*10^3 N/C

8 0
3 years ago
Will Give Brainliest
Tom [10]

Answer:

A hole within a hole

Explanation:

8 0
3 years ago
Question 9
Mama L [17]

Answer:
1. Make sure the regulator adjustment screws are completely backed out and loose.
2. Open the main cylinder valves slowly.
3. Set the Oxygen and Acetylene working pressures.

4. Light and adjust the torch.

Explanation:

5 0
1 year ago
The football team has a total of 20 jerseys. There are 6
nadezda [96]
20% of the jerseys are medium sized
3 0
3 years ago
Other questions:
  • Your driver license will be _____ if you race another driver on a public road, commit a felony using a motor vehicle, or are fou
    6·2 answers
  • For some transformation having kinetics that obey the Avrami equation , the parameter n is known to have a value of 1.1. If, aft
    6·1 answer
  • A gear train has two gears. The driver gear has 8 teeth and a diametral pitch of 6 teeth/inch. the follower gear has 24 teeth. W
    13·1 answer
  • What are four engineering degrees that can help lead you to becoming an aerospace engineer
    6·1 answer
  • Question 9 of 25
    12·1 answer
  • The electron beam in a TV picture tube carries 1015 electrons per second. As a design engineer, determine the voltage needed to
    8·1 answer
  • Zionjasean17 zionjasean17
    8·2 answers
  • A compressor receives air at 290 K, 95 kPa and shaft work of 5.5 kW from a gasoline engine. It should deliver a mass flow rate o
    7·1 answer
  • Do the coil resistances have any effect on the plots?
    10·1 answer
  • The metal control joints used to relieve stresses caused by expansion and contraction in large ceiling or wall expenses in inter
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!