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
A 12-ft circular steel rod with a diameter of 1.5-in is in tension due to a pulling force of 70-lb. Calculate the stress in the
padilas [110]

Answer:

The stress in the rod is 39.11 psi.

Explanation:

The stress due to a pulling force is obtained dividing the pulling force by the the area of the cross section of the rod. The respective area for a cylinder is:

A=\pi*D^2/4

Replacing the diameter the area results:

A= 17.76 in^2

Therefore the the stress results:

σ = 70/17.76 lb/in^2 = 39.11 lb/in^2= 39.11 psi

5 0
3 years ago
Conclusion. What process is responsible for the bubbling action of the organism? What is your evidence?
noname [10]

Answer:

Explanation:

Hands-on Activity Bubbling Plants Experiment to Quantify Photosynthesis ... After running the experiment, students pool their data to get a large sample ... Explain that photosynthesis is a process that plants use to convert light ... Describe a simple experiment that provides indirect evidence that photosynthesis is occurring.

Through photosynthesis, certain organisms convert solar energy (sunlight) into ... of our planet continuously and is transferred from one organism to another. Therefore, directly or indirectly, the process of photosynthesis provides most of the energy ... Biology in Action ... Chlorophyll is responsible for the green color of plants.Photosynthetic organisms capture energy from the sun and matter from the air to ... oxygen produced during photosynthesis makes leaf bits float like bubbles in water. ... their ability to carry out photosynthesis, the biochemical process of capturing ... this air is forced out and replaced with solution, causing the leaves to sink.

6 0
3 years ago
What’s the answer please help
irina1246 [14]

Answer:

It B

Explanation:

4 0
3 years ago
Define extensive and intensive properties of thermodynamic system.
Flura [38]

Answer:

An intense property is a physical attribute of a system that is independent of the size of the system or the quantity of material it contains. An extensive property of a system, on the other hand, is dependent on the size of the system or the amount of material in it.

Explanation:

7 0
3 years ago
Read 2 more answers
Based on these statements:
Evgen [1.6K]

Answer:

the third statement is true

Explanation:

given data

Lenovos cost more than Dells

Lenovos cost less than Apples

solution

we have given 1st statement that is express as

cost (Lenovo) > cost (Dell)     ..................1

and

2nd statement that is express as

cost (Lenovo) < cost (Apple)

so we can say it as

cost (Apple) > cost (Lenovo)       ......................2

and

now above Both equation 1 and 2 can be written as

cost (Apple) > cost (Lenovo) > cost (Dell)      .........................3

so we can say cost of Apples is more than the cost of Lenovos and the cost of Dells

so as that given 3rd statement is true

7 0
3 years ago
Other questions:
  • List the thermal conductivities of five
    15·1 answer
  • What is EL Niño?
    9·1 answer
  • 2.14 (a) Using series/parallel resistance reductions, find the equivalent resistance between terminals A and B in the circuit of
    14·1 answer
  • The design specifications of a 1.2-m long solid circular transmission shaft require that the angle of twist of the shaft not exc
    15·1 answer
  • Question 54 (1 point)
    11·2 answers
  • Why dues brainy exist as a learning platform when it is just full of answers and you won't learn anything?
    8·1 answer
  • List a minimum of four reasons why you might be rejected for a job offer.
    10·1 answer
  • O local utilizado pelos grandes avioes para descolar e aterrar
    14·1 answer
  • 4 points
    13·1 answer
  • What is the purpose of having a ventilation system on board a motorized vessel?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!