Out: Tue 3 Feb 1998 Due: During Lab Session
Programming Assignment:
Write, compile and run the Temperature.java program to calculate convert a value input in Celcius to Farenheit, or a value input in Farenheit to Celcius.
First the program should prompt the user for the target units, with the user entering either "Farenheit" or "Celcius". Then the user is prompted for a temperature value which is converted. Here is an example:
appomattox> java Temperature Convert to (Celcius/Farenheit)? Farenheit Temperature: 100.0 100.0 Celcius = 212.0 Farenheit. appomattox>To read a String and convert it to a double data object use the magic incantation:
double x ; x = (Double.valueOf(stdin.readLine())).doubleValue() ;Use readLine to get the String containing either Celcius or Farenheit, and then compare it to the text literal "Celcius" using the magic incantation:
System.out.print("Convert to (Celcius/Farenheit)? ") ; String answer ; answer = stdin.readLine() ; if ( answer.equals("Celcius") ) { // if you are running this code, then the string equals Celcius }
Use PostIt to submit your homework. There are further instructions about how to do this.