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
What is civil engineering​
kkurt [141]

Answer:

engineering that works on building structures.

Explanation:

7 0
4 years ago
1. Technician A says an automotive computer can scan its input and output circuits to detect incorrect voltage problems. Technic
Marta_Voda [28]
B is the correct answer
4 0
3 years ago
Do the coil resistances have any effect on the plots?
PolarNik [594]
Because of the skin depth effect, the current at high frequency tends to flow at very low depth from radius. Then at high frequency the effective cross section of the wire is narrower than at DC.

Fro example skin depth at 100 kHz is 0.206 mm (0.008”), a wire more thicker than AWG26 could be a waste of copper, better use a bunch of thin wire (Litz wire) to rise the Q factor.
8 0
3 years ago
How can I find the quotient of 27 divided 91.8
gayaneshka [121]
Step 1:
Start by setting it up with the divisor 8 on the left side and the dividend 27 on the right side like this:

8 ⟌ 2 7

Step 2:
The divisor (8) goes into the first digit of the dividend (2), 0 time(s). Therefore, put 0 on top:

0
8 ⟌ 2 7

Step 3:
Multiply the divisor by the result in the previous step (8 x 0 = 0) and write that answer below the dividend.

0
8 ⟌ 2 7
0

Step 4:
Subtract the result in the previous step from the first digit of the dividend (2 - 0 = 2) and write the answer below.

0
8 ⟌ 2 7
- 0
2

Step 5:
Move down the 2nd digit of the dividend (7) like this:

0
8 ⟌ 2 7
- 0
2 7

Step 6:
The divisor (8) goes into the bottom number (27), 3 time(s). Therefore, put 3 on top:

0 3
8 ⟌ 2 7
- 0
2 7

Step 7:
Multiply the divisor by the result in the previous step (8 x 3 = 24) and write that answer at the bottom:

0 3
8 ⟌ 2 7
- 0
2 7
2 4

Step 8:
Subtract the result in the previous step from the number written above it. (27 - 24 = 3) and write the answer at the bottom.

0 3
8 ⟌ 2 7
- 0
2 7
- 2 4
3

You are done, because there are no more digits to move down from the dividend.

The answer is the top number and the remainder is the bottom number.

Therefore, the answer to 27 divided by 8 calculated using Long Division is:

3
8 0
3 years ago
What are some of the main causes of accidents?
Ainat [17]

Answer

Being drunk, texting, being distracted

Explanation:

Hope this helped.

3 0
4 years ago
Other questions:
  • 3. An isolated system has an initial temperature of 30oC. It is then placed on top of a Bunsen burner whose temperature is 70oC
    10·1 answer
  • Consider two identical 86-kg men who are eating identical meals and doing identical things except that one of them jogs for 30 m
    10·1 answer
  • Select the correct verb form to complete each of the following sentences.Members of the committee ____ issued a mobile phone and
    8·1 answer
  • A 35kg block of mass is subjected to forces F1=100N and F2=75N at agive angle thetha= 20° and 35° respectively.find the distance
    11·1 answer
  • The passage says that the president's guests "believed the rest at the 'Little
    13·1 answer
  • You have discovered an element that is a poor conductor of electricity, has a low melting point, and is a gas at room temperatur
    6·1 answer
  • Someone please help me and explain this in detail!!!!!
    9·1 answer
  • Tech A says that a mechanical pressure regulator exhausts excess fluid back to the transmission pan. Tech B says that if the tra
    9·1 answer
  • A liquid mixture containing 0.45 mol fraction of heptane and 0.55 mole fraction ethyl benzene is fed as saturated vapor to a dis
    12·1 answer
  • A full wave bridge rectifier is used to charge a battery of 24 V and 120 W-H. If the supply voltage with 220 V is used to feed t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!