In this assignment, you will write your own program to perform basic math operations to implement temperature conversions.
In the following, the Romer scale is shown as Romer. The letter o is distinct from the letter o. Typing these other characters can be complicated and having them appear properly when you run your program may require adjustments. If you are interested in this, you are welcome to experiment within the program to see what happens, but it is equally fine to substitute o for o in this assignment.
Throughout history, a number of different systems have been devised to measure temperature. You are going to write a program that starts with a temperature in degrees Fahrenheit and converts it into four other systems. All of these systems are named after their inventors, including the kelvin. The kelvin is the base unit of temperature in the International System of Units (SI), similar to the meter and liter and should not have "degrees" in front or be capitalized when used to display a temperature.
Programming is all about breaking bigger problems into smaller ones. As you approach this program, don't try to sort out all four conversions at the same time. Start off smaller and aim for the program to just convert Fahrenheit to Celsius and display that result. Once that works, add similar lines of code for the other temperature systems one at a time.
1. Use your IDE to write a program. The required name for this program is Temperature.
2. Use only the syntax taught to you so far. You do not need any other functions that we have not yet learned in class.
3. Your program will convert temperatures from degrees Fahrenheit to degrees Celsius, kelvins, degrees Delisle, and degrees Rmer. The equations required are:
celsius = (Fahrenheit – 32) x 5/9
kelvin = Celsius + 273.15
delisle = (100 – celsius) x 3/2
romer = (fahrenheit - 32) x 7/24 + (7 and 1/2)
4. For reasons that will become clearer later in this chapter, when you convert the formula, if you use expressions like (5/9) with two integers, you will always end up with 0 which will throw off the computations. You need to use (5.0/9.0) to get the right result.
5. Create a program that allows the user to enter a temperature in degrees Fahrenheit, converts it to the corresponding temperatures in degrees Celsius, kelvins, degrees Delisle, and degrees Romer, then displays all the values.
6. You will need to declare variables for all five temperatures. Declare the variables as double, not int, since they involve decimal points.
7. You must use cout to ask the user to enter the temperature in degrees Fahrenheit and then accept the user's input using cin.
8. Any fraction that appears in the equations that has an exact decimal equivalent can be written using its decimal form. Do not replace 5/9 or 7/24 by a decimal approximation of those values.
9. Your program must use arithmetic expressions to compute the four other temperatures.
.0. Your print statement to display the temperatures may not include any hardcoded values for any values. You may not hardcode any of the temperatures into the printed strings. Hardcoding means to put in values in statements rather than using the identifiers.
.1. Try running your program four times with the test values 101.5, 98.6, -40.0, and -459.67. In future assignments, you will need to come up with test case values on your own. As you look at the outputs, think about why these specific values were chosen for this test.
.2. Be sure your program produces output consistent with the Required Output shown below.
.3. If you have questions, use the information from the course home page to reach out for help.
Temperature.java
Temperature in degrees Fahrenheit
Here is an example of the output when the user enters 101.5 It must include your name as well.
Temperature - Chris Zagar
Enter temperature in degrees Fahrenheit: 101.5
101.5 degrees Fahrenheit = 38.6111 degrees Celsius
101.5 degrees Fahrenheit = 311.761 kelvins
101.5 degrees Fahrenheit = 92.0833 degrees Delisle
101.5 degrees Fahrenheit = 27.7708 degrees Romer
Due to rounding errors, the final decimals of your answers may be slightly different than this example, but your answers should include decimals and should be very close to these values.