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 well-insulated, rigid tank has a volume of 1 m3and is initially evacuated. A valve is opened,and the surrounding air enters at
DiKsa [7]

Answer:

0.5 kW

Explanation:

The given parameters are;

Volume of tank = 1 m³

Pressure of air entering tank = 1 bar

Temperature of air = 27°C = 300.15 K

Temperature after heating  = 477 °C = 750.15 K

V₂ = 1 m³

P₁V₁/T₁ = P₂V₂/T₂

P₁ = P₂

V₁ = T₁×V₂/T₂ = 300.15 * 1 /750.15 = 0.4 m³

dQ = m \times c_p \times (T_2 -T_1)

For ideal gas, c_p = 5/2×R = 5/2*0.287 = 0.7175 kJ

PV = NKT

N = PV/(KT) = 100000×1/(750.15×1.38×10⁻²³)

N = 9.66×10²⁴

Number of moles of air = 9.66×10²⁴/(6.02×10²³) = 16.05 moles

The average mass of one mole of air = 28.8 g

Therefore, the total mass = 28.8*16.05 = 462.135 g = 0.46 kg

∴ dQ = 0.46*0.7175*(750.15 - 300.15) = 149.211 kJ

The power input required = The rate of heat transfer = 149.211/(60*5)

The power input required = 0.49737 kW ≈ 0.5 kW.

3 0
3 years ago
What type of engineer makes sure equipment is safe and operational
zvonat [6]

Answer:

mechanical engineer is the best answer

8 0
3 years ago
What is the Energy of moving things?<br><br> mechanical<br> sound<br> nuclear<br> Light
Elenna [48]

Answer: Kinetic energy

Explanation: If you live in a country other than UK you will probably call it something different

4 0
3 years ago
Read 2 more answers
2.1 What is the minimum number of pins required for a so-called dual-op-amp IC package, one containing two op amps? What is the
cupoosta [38]

Answer:

8 for dual-op-amp package, and 14 for quad-op-amp

Explanation;

This is because every op-amp has 2 input terminal 4 pns

So one output terminal that is 2 pins which are required for power

and the same for a minumum number of pins required by quad op amp which is 14

5 0
3 years ago
A missile flying at high speed has a stagnation pressure and temperature of 5 atm and 598.59 °R respectively. What is the densit
alexdok [17]

Answer:

5.31\frac{kg}{m^3}

Explanation:

Approximately, we can use the ideal gas law, below we see how we can deduce the density from general gas equation. To do this, remember that the number of moles n is equal to \frac{m}{M}, where m is the mass and M the molar mass of the gas, and the density is \frac{m}{V}.

For air M=28.66*10^{-3}\frac{kg}{mol} and \frac{5}{9}R=K

So, 598.59 R*\frac{5}{9}=332.55K

pV=nRT\\pV=\frac{m}{M}RT\\\frac{m}{V}=\frac{pM}{RT}\\\rho=\frac{pM}{RT}\\\rho=\frac{(5atm)28.66*10^{-3}\frac{kg}{mol}}{(8.20*10^{-5}\frac{m^3*atm}{K*mol})332.55K}=5.31\frac{kg}{m^3}

7 0
4 years ago
Other questions:
  • Does a thicker core make an electromagnet stronger?
    13·1 answer
  • Which of the following does NOT describe product design.
    11·1 answer
  • Vehicles arrive at a single toll booth beginning at 8:00 A.M. They arrive and depart according to a uniform deterministic distri
    9·1 answer
  • Technician A says that when using an impact wrench to remove a bolt from the front of an engine's crankshaft, the crankshaft mus
    15·1 answer
  • Plz help me
    12·1 answer
  • Helium gas expands in a piston-cylinder in a polytropic process with n=1.67. Is the work positive, negative or zero?
    8·1 answer
  • A heat engine operates between 2 reservoirs at TH and 18oC. The heat engine receives 17,000 kJ/h from the high temperature reser
    10·1 answer
  • How do guest room hotel smoke alarms work and differ then regular home versions?
    10·2 answers
  • Technician A that shielding gas nozzles may have different shapes. Technician B says that gelding gas nozzles is attached to the
    8·1 answer
  • Water is pumped from a lake to a storage tank 18 m above at a rate of 70 L/s while consuming 20.4 kW of electric power. Disregar
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!