This program will give the user two options – to convert centimeters to inches, inches to centimeters, or to exit.  Ask the user if they’d like to convert cm to inches, inches to cm, or if they’d like to exit. If they choose to convert, ask them for their numeric input, do the math, and output the result to them. The loop should then repeat and the menu should be reprinted for them to select again. If they choose to exit, the program should end cleanly. (“Cleanly” means we do not ask for more input or do any math. However, you are encouraged to add a “goodbye” statement.) If they choose an invalid option for the menu, tell them that they entered an invalid option, reprint the menu, and let them enter again. You do not have to account for negative centimeters. Simply do the math and let a negative answer be given. Use a while loop to complete this program. Consider using an if/else statement inside your loop.  Consider using a Boolean variable to control the loop.  Program should be able to accept real numbers and output should be decimal formatted.   Sample output:   This program will convert units of measurements   Type 1 if you want to convert cm to inches. Type 2 if you want to convert inches to cm. Type 3 if you want to exit the program. >>>1 Enter your number in centimeters: >>>30.0 This is equal to 11.81 inches.   Type 1 if you want to convert cm to inches. Type 2 if you want to convert inches to cm. Type 3 if you want to exit the program. >>>2 Enter your number in inches: >>>100 This is equal to 254.00 cm.   Type 1 if you want to convert cm to inches. Type 2 if you want to convert inches to cm. Type 3 if you want to exit the program. >>>5 Invalid Input.   Type 1 if you want to convert cm to inches. Type 2 if you want to convert inches to cm. Type 3 if you want to exit the program. >>>3 Goodbye. in java

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter8: Advanced Data Handling Concepts
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

This program will give the user two options – to convert centimeters to inches, inches to centimeters, or to exit. 

  1. Ask the user if they’d like to convert cm to inches, inches to cm, or if they’d like to exit.
  2. If they choose to convert, ask them for their numeric input, do the math, and output the result to them. The loop should then repeat and the menu should be reprinted for them to select again.
  3. If they choose to exit, the program should end cleanly. (“Cleanly” means we do not ask for more input or do any math. However, you are encouraged to add a “goodbye” statement.)
  4. If they choose an invalid option for the menu, tell them that they entered an invalid option, reprint the menu, and let them enter again.
  5. You do not have to account for negative centimeters. Simply do the math and let a negative answer be given.
  6. Use a while loop to complete this program. Consider using an if/else statement inside your loop.  Consider using a Boolean variable to control the loop.  Program should be able to accept real numbers and output should be decimal formatted.

 

Sample output:

 

This program will convert units of measurements

 

Type 1 if you want to convert cm to inches.

Type 2 if you want to convert inches to cm.

Type 3 if you want to exit the program.

>>>1

Enter your number in centimeters:

>>>30.0

This is equal to 11.81 inches.

 

Type 1 if you want to convert cm to inches.

Type 2 if you want to convert inches to cm.

Type 3 if you want to exit the program.

>>>2

Enter your number in inches:

>>>100

This is equal to 254.00 cm.

 

Type 1 if you want to convert cm to inches.

Type 2 if you want to convert inches to cm.

Type 3 if you want to exit the program.

>>>5

Invalid Input.

 

Type 1 if you want to convert cm to inches.

Type 2 if you want to convert inches to cm.

Type 3 if you want to exit the program.

>>>3

Goodbye.

in java

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Basics of loop
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage