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
Explain how feedback control is used to<br> adjust robotic movements.
LuckyWell [14K]

Answer:

Feedback control of arm movements using Neuro-Muscular Electrical Stimulation (NMES) combined with a lockable, passive exoskeleton for gravity compensation

6 0
2 years ago
A 3-phase , 1MVA, 13.8kV/4160V, 60 Hz, transformer with Y-Delta winding connection is supplying a3-phase, 0.75 p.u. load on the
Tanya [424]

Answer:

a) 23.89 < -25.84 Ω

b) 31.38 < 25.84 A

c) 0.9323 leading

Explanation:

A) Calculate the load Impedance

current on load side = 0.75 p.u

power factor angle = 25.84

I_{load} = 0.75 < 25.84°

attached below is the remaining part of the solution

<u>B) Find the input current on the primary side in real units </u>

load current in primary = 31.38 < 25.84 A

<u>C) find the input power factor </u>

power factor = 0.9323 leading

<em></em>

<em>attached below is the detailed solution </em>

8 0
2 years ago
The following are the results of a sieve analysis. U.S. sieve no. Mass of soil retained (g) 4 0 10 18.5 20 53.2 40 90.5 60 81.8
il63 [147K]

Answer:

a.)

US Sieve no.                         % finer (C₅ )

4                                                  100

10                                                95.61

20                                               82.98

40                                               61.50

60                                               42.08

100                                              20.19

200                                              6.3

Pan                                               0

b.) D10 = 0.12, D30 = 0.22, and D60 = 0.4

c.) Cu = 3.33

d.) Cc = 1

Explanation:

As given ,

US Sieve no.             Mass of soil retained (C₂ )

4                                            0

10                                          18.5

20                                         53.2

40                                         90.5

60                                         81.8

100                                        92.2

200                                       58.5

Pan                                        26.5

Now,

Total weight of the soil = w = 0 + 18.5 + 53.2 + 90.5 + 81.8 + 92.2 + 58.5 + 26.5 = 421.2 g

⇒ w = 421.2 g

As we know that ,

% Retained = C₃ = C₂×\frac{100}{w}

∴ we get

US Sieve no.               % retained (C₃ )               Cummulative % retained (C₄)

4                                            0                                           0

10                                          4.39                                      4.39

20                                         12.63                                     17.02

40                                         21.48                                     38.50

60                                         19.42                                     57.92

100                                        21.89                                     79.81

200                                       13.89                                     93.70

Pan                                        6.30                                      100

Now,

% finer = C₅ = 100 - C₄

∴ we get

US Sieve no.               Cummulative % retained (C₄)          % finer (C₅ )

4                                                     0                                          100

10                                                  4.39                                      95.61

20                                                 17.02                                     82.98

40                                                 38.50                                    61.50

60                                                 57.92                                    42.08

100                                                79.81                                     20.19

200                                                93.70                                   6.3

Pan                                                 100                                        0

The grain-size distribution is :

b.)

From the diagram , we can see that

D10 = 0.12

D30 = 0.22

D60 = 0.12

c.)

Uniformity Coefficient = Cu = \frac{D60}{D10}

⇒ Cu = \frac{0.4}{0.12} = 3.33

d.)

Coefficient of Graduation = Cc = \frac{D30^{2}}{D10 . D60}

⇒ Cc = \frac{0.22^{2}}{(0.4) . (0.12)} = 1

3 0
2 years ago
Three point bending is better than tensile for evaluating the strength of ceramics. a)-True b)- False
amid [387]

Answer:

a)-True

Explanation:

Three point bending is better than tensile for evaluating the strength of ceramics. It is got a positive benefit to tensile for evaluating the strength of ceramics.

5 0
3 years ago
By using hydraulic cylinders of
JulsSmile [24]

Answer:

C

Explanation:

Hydraulic systems can increase or decrease the force applied to them. To make the force larger, the pressure is applied to a larger area. For example, if a 100-N force is applied to the left cylinder in (Figure) and the right cylinder has an area five times greater, then the output force is 500 N.

3 0
2 years ago
Other questions:
  • Why do electricians require critical thinking skills? In order to logically identify alternative solutions to problems in order
    8·1 answer
  • How does java achieve portable
    13·1 answer
  • A block of mass 0.75 kg is suspended from a spring having a stiffness of 150 N/m. The block is displaced downwards from its equi
    5·2 answers
  • Which of the following tells the computer wha to do
    12·1 answer
  • Given two alphabet strings str1 and str2. You can change the characters in str1 to any alphabet characters in order to transform
    8·1 answer
  • The value of universal gas constant is same for all gases?<br> a) yes<br> b)No
    15·1 answer
  • The toughness of a material does what, when it's been heated?​
    7·1 answer
  • When asked about favorite Thanksgiving leftovers, 9% of the people said turkey and 7100 said mashed potatoes. Which food is more
    7·1 answer
  • By adding "-once", one can form the noun form of the word "organize" is that true or false?​
    5·2 answers
  • The section of the area to be examined is shown circumscribed by broken lines with circles at
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!