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
If the bolt head and the supporting bracket are made of the same material having a failure shear stress of 'Tra;i = 120 MPa, det
Nina [5.8K]

Answer:

P=361.91 KN

Explanation:

given data:

brackets and head of the screw are made of material with T_fail=120 Mpa

safety factor is F.S=2.5

maximum value of force P=??

<em>solution:</em>

to find the shear stress

                            T_allow=T_fail/F.S

                                         =120 Mpa/2.5

                                         =48 Mpa

we know that,

                               V=P

<u>Area for shear head:</u>

                              A(head)=π×d×t

                                           =π×0.04×0.075

                                           =0.003×πm^2

<u>Area for plate:</u>

                               A(plate)=π×d×t  

                                            =π×0.08×0.03

                                            =0.0024×πm^2

now we have to find shear stress for both head and plate

<u>For head:</u>

                                   T_allow=V/A(head)

                                    48 Mpa=P/0.003×π                 ..(V=P)

                                             P =48 Mpa×0.003×π

                                                =452.16 KN

<u>For plate:</u>

                                   T_allow=V/A(plate)

                                    48 Mpa=P/0.0024×π                 ..(V=P)

                                             P =48 Mpa×0.0024×π

                                                =361.91 KN

the boundary load is obtained as the minimum value of force P for all three cases. so the solution is

                                                P=361.91 KN

note:

find the attached pic

7 0
3 years ago
HW6P2 (20 points) The recorded daily temperature (°F) in New York City and in Denver, Colorado during the month of January 2014
Maurinko [17]

Answer & Explanation:

function Temprature

NYC=[33 33 18 29 40 55 19 22 32 37 58 54 51 52 45 41 45 39 36 45 33 18 19 19 28 34 44 21 23 30 39];

DEN=[39 48 61 39 14 37 43 38 46 39 55 46 46 39 54 45 52 52 62 45 62 40 25 57 60 57 20 32 50 48 28];

%AVERAGE CALCULATION AND ROUND TO NEAREST INT

avgNYC=round(mean(NYC));

avgDEN=round(mean(DEN));

fprintf('\nThe average temperature for the month of January in New York city is %g (F)',avgNYC);

fprintf('\nThe average temperature for the month of January in Denvar is %g (F)',avgDEN);

%part B

count=1;

NNYC=0;

NDEN=0;

while count<=length(NYC)

   if NYC(count)>avgNYC

       NNYC=NNYC+1;

   end

   if DEN(count)>avgDEN

        NDEN=NDEN+1;

   end

   count=count+1;

end

fprintf('\nDuring %g days, the temprature in New York city was above the average',NNYC);

fprintf('\nDuring %g days, the temprature in Denvar was above the average',NDEN);

%part C

count=1;

highDen=0;

while count<=length(NYC)

   if NYC(count)>DEN(count)

       highDen=highDen+1;

   end

   count=count+1;

end

fprintf('\nDuring %g days, the temprature in Denver was higher than the temprature in New York city.\n',highDen);

end

%output

check the attachment for additional Information

8 0
3 years ago
A police officer in a patrol car parked in a 70 km/h speed zone observes a passing automobile traveling at a slow, constant spee
Ludmilka [50]

Answer:

S = 0.5 km

velocity of motorist = 42.857 km/h

Explanation:

given data

speed  = 70 km/h

accelerates uniformly = 90 km/h

time = 8 s

overtakes motorist =  42 s

solution

we know  initial velocity u1 of police = 0

final velocity u2 = 90 km/h = 25 mps

we apply here equation of motion

u2 = u1 + at  

so acceleration a will be

a = \frac{25-0}{8}

a = 3.125  m/s²

so

distance will be

S1 = 0.5 × a × t²

S1 = 100 m = 0.1 km

and

S2 = u2 ×  t

S2 = 25  × 16

S2 = 400 m = 0.4 km  

so total distance travel by police

S = S1 + S2

S = 0.1 + 0.4

S = 0.5 km

and

when motorist travel with  uniform velocity

than total time = 42 s

so velocity of motorist will be

velocity of motorist = \frac{S}{t}

velocity of motorist =  \frac{500}{42}  

velocity of motorist = 42.857 km/h

3 0
3 years ago
Timken rates its bearings for 3000 hours at 500 rev/min. Determine the catalog rating for a ball bearing running for 10000 hours
svet-max [94.6K]

Answer:

C₁₀ = 6.3 KN

Explanation:

The catalog rating of a bearing can be found by using the following formula:

C₁₀ = F [Ln/L₀n₀]^1/3

where,

C₁₀ = Catalog Rating = ?

F = Design Load = 2.75 KN

L = Design Life = 1800 rev/min

n = No. of Hours Desired = 10000 h

L₀ = Rating Life = 500 rev/min

n₀ = No. of Hours Rated = 3000 h

Therefore,

C₁₀ = [2.75 KN][(1800 rev/min)(10000 h)/(500 rev/min)(3000 h)]^1/3

C₁₀ = (2.75 KN)(2.289)

<u>C₁₀ = 6.3 KN</u>

3 0
3 years ago
What is the locating position of the land field?​
Ivahew [28]

Any point on earth can be located by specifying its latitude and longitude, including Washington, DC, which is pictured here. Lines of latitude and longitude form an imaginary global grid system, shown in Fig. 1.17. Any point on the globe can be located exactly by specifying its latitude and longitude.

4 0
2 years ago
Other questions:
  • The boiler pressure is 38bar and the condenser pressure 0.032 bar.The saturated steam is superheated to 420 oC before entering t
    8·1 answer
  • Determine the direct runoff and streamflow given the following unit hydrograph. The rainfall is collected at 4-hour intervals an
    14·1 answer
  • Discuss four (4) advantages of direct and indirect water supply system.
    5·2 answers
  • At a festival, spherical balloons with a radius of 140.cm are to be inflated with hot air and released. The air at the festival
    10·1 answer
  • The Bureau of Labor and Statistics predicted that the field of biomedical engineering would increase by 62 percent over the comi
    5·1 answer
  • Hỗ trợ mình với được không các bạn
    13·1 answer
  • 11. Technicians A and B are discussing
    12·1 answer
  • Why might a hospital patient prefer to interact with a person instead of robot?
    13·1 answer
  • Who had launched the highest number of internet satellites as of March 2020?
    14·1 answer
  • 8. What is the purpose of the 300 Log?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!