CS 1713 Section 1 Spring 2011, Homework 1

Due on paper at the beginning of class, January 19, 2011.

Celsius / Fahrenheit Conversion

What To Do

Write a Java program that does the following:
  1. Prompt the user to enter '1' for Celsius to Fahrenheit, or '2' for Fahrenheit to Celsius.
  2. Prompt the user for a temperature.
  3. Convert the temperature using the conversion chosen in the first step.
  4. Print the original temperature and the converted temperature with meaningful output.
For example, an interactive session with the program might look like this:
Please enter '1' for Celsius, or '2' for Fahrenheit: 1
Please enter a temperature in degrees Celsius: 0
0 degrees Celsius is 32 degrees Fahrenheit.
Your program should give an error message and start prompting again if the user does not enter a 1 or 2 for the first step, e.g.:
Please enter '1' for Celsius, or '2' for Fahrenheit: 3
That is not a '1' or a '2'.  Please enter '1' for Celsius, or '2' for Fahrenheit: 2
Please enter a temperature in degrees Fahrenheit: 212
212 degrees Fahrenheit is 100 degrees Celsius

What To Turn In

Turn in a printout of your Java source code.

You may not work together on this assignment with other classmates or receive assistance from any person or sources other than your professor or TA.

Turn in this assignment at the beginning of class on Wednesday, January 19, 2011. You must turn in the assignment printed on paper using a printer at the beginning of class.

Late assignments will not be accepted.