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 the different methods to turn on thyrister and how can a thyrister turned off​
myrzilka [38]

Answer:

forward voltage triggering

temperature triggering

dv/dt triggering

light triggering

gate triggering

Then turning off;

Turn off is accomplished by a "negative voltage" pulse between the gate and cathode terminals

Explanation:

hope it helps

8 0
3 years ago
Consider liquid n-hexane in a 50-mm diameter graduated cylinder. Air blows across the top of the cylinder. The distance from the
ra1l [238]

The evaporation rate of the n-Hexane is 7.85 \times 10^{-6} \mathrm{mol} / \mathrm{s}

<u>Explanation</u>:

This is a situation regarding diffusing A through non-diffusing B.

A = n-Hexane B=Air

Where the molar flux is provided by,

N_{A}=D_{A B} P_{T}\left(P_{A 1}-P_{A 2}\right) / R T z P_{b m}

\mathrm{D}_{\mathrm{AB}}=8.8 \times 10^{-6} \mathrm{m}^{2} / \mathrm{s}

P_{t}=1 a t m=101325 P a\\

\text { so, } P_{A 1}= the vapor pressure at hexane 25 \mathrm{C} =20158.2 \mathrm{Pa}

For wind, assume negligible hexane is present, hence P_{A 2}=0

Now,

\mathrm{P}_{\mathrm{B} 1}=\mathrm{P}_{\mathrm{T}}-\mathrm{P}_{\mathrm{A} 1}=101325-20158.2 \mathrm{P}_{\mathrm{a}}

\mathrm{P}_{\mathrm{B} 2}=\mathrm{P}_{\mathrm{T}}-\mathrm{P}_{\mathrm{A} 2}=\mathrm{P}_{\mathrm{T}}=101325 \mathrm{Pa}

P_{B M}=\frac{\left(P_{B 2}-P_{B 1}\right)}{\log _{e}\left(P_{B 2} / P_{B 1}\right)}\\

=\frac{101325-81166.8}{\ln \left(\frac{101325}{81166.8}\right) \mathrm{Pa}}

=90873.57 \mathrm{Pa}

R=8.314 \mathrm{J} / \mathrm{mol}-\mathrm{K}

z=\text { distance }=20 \mathrm{cm}=0.2 \mathrm{m}\\

where T = 298 K

substituting all in the equation, we get

\begin{aligned}&\mathrm{N}_{\mathrm{A}}=\\&\left(8.8 \times 10^{-6} \mathrm{m}^{2} / \mathrm{s}\right) \times 101325 \mathrm{Pa} \times(20158.2 \mathrm{Pa}) /(8.314 \mathrm{J} / \mathrm{mol}-\mathrm{K} \times 0.2 \mathrm{m} \times 298 \mathrm{K}\\&\times 90873.57 \mathrm{Pa})\end{aligned}

=0.004 \mathrm{mol} / \mathrm{m}^{2} \mathrm{s}\\

Now,Flux \times area  = Molar rate of evaporation

Evaporation rate = 0.004 \mathrm{mol} / \mathrm{m}^{2}-5 \mathrm{x}\left(\pi \mathrm{d}^{2} / 4 \mathrm{m}^{2}\right)=0.004 \times(3.14 \times 0.05 \times 0.05 / 4)

Evaporation rate =7.85 \times 10^{-6} \mathrm{mol} / \mathrm{s}

6 0
3 years ago
A Carnot power cycle is executed in a piston-cylinder system using 1 kg of water. The cycle consists of an isobaric expansion of
jeka94

Answer:

b) Determine the heat transfer into the cycle and the net work for the cycle, in kJ.

Explanation:

5 0
4 years ago
Use the following assumptions for problems 1 and 2:
Salsk061 [2.6K]

Answer:

The text file attached has the detailed solution of all the parts individually.

Download txt
6 0
3 years ago
Cool water at 15°C is throttled from 5(atm) to 1(atm), as in a kitchen faucet. What is the temperature change of the water? What
Tresset [83]

Answer:

the lost work per kilogram of water for this everyday household happening = 0.413 kJ/kg

Explanation:

Given that:

Initial Temperature T_1 = 15°C

Initial Pressure P_1 = 5 atm

Final Pressure P_2 = 1 atm

Data obtain from steam tables of saturated water at  15°C are as follows:

Specific volume  v = 1.001 cm³/gm

The change in temperature = 2°C

Specific heat of water = 4.19 J/gm.K

volume expansivity β = 1.5 × 10⁻⁴ K⁻¹

The expression to determine the change in temperature can be given as :

\delta \ T = \frac{-V (1- \beta \ T}{C_p} * \delta \ P ( \frac{1}{9.87} \ \frac{J}{cm^3/atm})\delta \ T = \frac{-1.001 \frac{cm^3}{gm} (1- 1.5*10^{-4} \  K^{-1} )*2}{4.19 \ \frac{J}{gm.K}} *(5-1)atm ( \frac{1}{9.87} \ \frac{J}{cm^3/atm})

Δ T = 0.093 K

Now; we can calculate the lost work bt the formula:

W_{lost} = T_{surr} *S

where ;

T_{surr} is the temperature of the surrounding. = 20°C = (20+273.15)K =  293.15 K

From above the change in entropy is:

\delta \  S = C_p \  In (\frac{T+ \delta \ T }{T}) *  \beta V \delta P

\delta \  S = 4.19*  \  In (\frac{288.15+0.093 }{288.15}) -  1.5*10^{-4} * 1.001 (5-1)* (\frac{1}{9.87})

\delta \  S =1.408*10^{-3} \ J/gm.K

W_{lost} = T_{surr} *S

W_{lost} = 293.15* 1.408*10^{-3} \ J/gm.K

W_{lost} = 0.413 \  kJ/kg

Thus, the lost work per kilogram of water for this everyday household happening = 0.413 kJ/kg

6 0
4 years ago
Other questions:
  • Early mountaineers boiled water to estimate their altitude. If they reached the top and found that water boiled at 89°C, approxi
    14·1 answer
  • Automobiles must be able to sustain a frontal impact. Specifically, the design must allow low speed impacts with little damage,
    9·1 answer
  • In a mechanical assembly operation, the first work unit required 7.83 min to complete and the learning rate for mechanical assem
    9·1 answer
  • Guess my birthday it’s in September you should be good with it
    6·1 answer
  • Name some of the traits that Darwin studied in the Galapagos finches.
    8·2 answers
  • Sort the following alphabets using MergeSort and give required steps. [2 Marks]
    9·1 answer
  • 3. Sitúese en la época de los faraones en Egipto. Usted es el encargado de construir una de esas fabulosas pirámides que fueron
    11·1 answer
  • PLEASE I NEED HELP!
    9·1 answer
  • Consider an infinite lattice with coordination number z in which every site is occupied by a molecule. (As a reminder, the coord
    5·1 answer
  • What would be the structure for the body points for a persuasive presentation?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!