Introduction
This lab is designed to give you a simple, start-to-finish, real world application of what we have learned so far. It makes use of your ability to read strings from the user, convert them to doubles, write and use methods, perform computations, &c.
The Assignment
Please write a program in the context of a class specification named TempuratureConversion. It should consist of three methods:
Note: The equation for converting from Fahrenheit to Centigrade is:
- fahrenheitToCentigrade -- this should accept a tempurature, in fahrenheit, expressed as a double, and return the equivalent tempuerature in Centigrade, also expressed as a double.
- getTempFromUser -- this method should accept no arguments. It should prompt the user for a tempurature in fahrenheit, accept the user input as a String, convert this String to a double, and return the double.
- main -- this should be the traditional starting point method. It should use getTempFromUser() and fahrenheitToCentigrade to prompt the user for a tempurature in Fahrenheit, convert it to Centigrade, and then display the result.
Tc = (5/9) * (Tf - 32)
Sample Output
Below is an example run of the program. The user's input is shown in italics.
Enter tempurature in Fahrenheit: 72 The tempurature in Centigrade is: 22.22222222222222Important note: Your result might be slightly different due to the precision of float-point-type numbers.
We'll talk about this on Friday.