Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert to kilometers Convert to inches Convert to feet Quit the program The program will convert the distance to kilometers, inches and feet, depending on

Convert to kilometers

Convert to inches

Convert to feet

Quit the program

The program will convert the distance to kilometers, inches and feet, depending on the user’s selections. Here are the specific requirements:

Write a void method named show Kilometers, which accept the number of meters as an argument. The method should display the argument converted to kilometers. Convert the meters to kilometers using the following formula:

Kilometers = meters*0.001

Write a void method named show Inches, which accept the number of meters as an argument. The method should display the argument converted to inches. Convert the meters to inches using the following formula:

Inches = meters*39.37

Write a void method named show Feet, which accept the number of meters as an argument. The method should display the argument converted to feet. Convert the meters to feet using the following formula:

Feet = meters*3.281

Write void method named menu that displays the menu of selections. This method should not accept any arguments.

The program should continue to display the menu until the user enters 4 to quit the program.

The program should not accept negative numbers for the distance in meters.

If the user selects an invalid choice from menu, the program should display an error message.

Here is an example session with the program, using console input. The user’s input is shown in bold.

Enter a distance in meters: 500[Enter]

Convert to kilometers

Convert to inches

Convert to feet

Quit the program

Enter your choice: 1 [Enter]

500 meters is 0.5 kilometers.

Convert to kilometers

Convert to inches

Convert to feet

Quit the program

Enter your choice: 3[Enter]

500 meters is 1640.5 feet.

Convert to kilometers

Convert to inches

Convert to feet

Quit the program

   

 

 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import javautilScanner class ConversionProgram public static void main String args Scanner input new ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Calculus

Authors: Dale Varberg, Edwin J. Purcell, Steven E. Rigdon

9th edition

131429248, 978-0131429246

More Books

Students also viewed these Accounting questions

Question

Which are the strongest parts?

Answered: 1 week ago

Question

Which character has an opposite script?

Answered: 1 week ago