Write a program that allows the user to convert a temperature given in
degrees from either Celsius to Fahrenheit or Fahrenheit to Celsius. Use the following formulas:
Degrees_C = 5 (Degrees_F ? 32) / 9
Degrees_F = (9 (Degrees_C) / 5) + 32
Prompt the user to enter a temperature and either a C or c for Celsius or an F or f for Fahrenheit. Convert the temperature to Fahrenheit if Celsius is entered, or to Celsius if Fahrenheit is entered. Display the result in a readable format. If anything other than C, c, F, or f is entered, print an error message and stop.
This project uses selection to enhance the program FtoC developed in Chapter 2. The solution includes a default case if an incorrect character (anything other than a ‘C’ or ‘F’, either upper or lower case) is entered for the units. A common error is to write the while control expression as an OR instead of an AND, so the loop does not end when either ‘Q’ or ‘q’ is entered. With an OR expression one or both sides of the expression will always be true (if ‘Q’ is entered, the variable quit is not equal to ‘q’, and vice versa); quit must be both not equal to ‘Q’ and not equal to ‘q’ to enter the loop.
See the code in TemperatureConversionSelection.java.
You might also like to view...
ActiveX controls are identified using the ____ attribute.
A. src B. classelem C. classid D. data
A calculation is based on a(n) ___________-the step-by-step process by which numbers are manipulated.
Fill in the blank(s) with the appropriate word(s).
Nmap has a GUI front end that makes it easier to work with some of the complex options by providing a GUI. Which of the following is the Nmap GUI front end?
A. Nmap GUI B. Fping C. Zenmap D. Hping
The maximum length for a 10BaseFL cable is up to ____________________ kilometers, depending on how you configure it.
Fill in the blank(s) with the appropriate word(s).