Fall 2012, The College of Saint Rose

Lab 7: Temperature Conversion
Due: 11:59 PM, Wednesday, October 31, 2012

For this lab assignment, your task is to write a program to display a series of temperature conversions from Fahrenheit to Celsius.

You will develop and submit both a Visual Logic flowchart and a Java program.

You may work alone or with a partner on this lab.

Temperature Conversions

The formula to convert a temperature in Fahrenheit to Celsius is:

```C = (F - 32) * 5 / 9
```

All temperature values are assumed to be real numbers (so we will use floating point double values).

Getting Set Up

• Create a folder for your work on this lab. Lab7 might be a good name.
• Follow the usual procedure (you can see all the detailed steps on the Lab 1 page) to create a new BlueJ project called Lab7Progs. We will not create any Java classes just yet.
• When you do create your flowchart, call it TempConvert.vls, and when you create your Java file, call it TempConvert.java.

Lab Procedure

Your programs will perform a series of conversions. From a given starting temperature, you will display the conversion table for the starting temperature and several more temperatures in increments of 5 degrees from the first. The user of your programs will enter 2 numbers: the starting temperature, and the number of incremental temperatures to be converted.

For example, if a starting temperature of 40 is specified along with a total of 8 incremental temperatures, the output would be:

```40.0F = 4.4C
45.0F = 7.2C
50.0F = 10.0C
55.0F = 12.8C
60.0F = 15.6C
65.0F = 18.3C
70.0F = 21.1C
75.0F = 23.9C
```

You should use a for loop, first in Visual Logic, then in Java, to accomplish this. Your loop should be a counting loop, executing a total number of times equal to the number entered by the user of your program. Each time through the loop, you will need to calculate and print out the Celsius equivalent for a Fahrenheit temperature, then increment the temperature to be converted on the next iteration by 5 degrees.

• Do not worry about output formatting for your Visual Logic flowchart. For Java, make sure your temperatures have at least one digit before the decimal place (consider a temperature of 0.5 degrees) and exactly one digit after.
• In Java, use a named constant for the temperature increment.

You can earn bonus points for enhancements of your choice. Some possibilities include providing conversion of F to C or C to F depending on an additional input, converting to other temperature scales in addition to C, or specifying both a starting and stopping temperature, and adjusting the increment so the requested number of temperatures are printed.

Style and Documentation Reminders

Before you submit your programs, make sure they conform to our guidelines for style and documentation.

In particular, you should have a comment at the top of each class that describes your program and has your name (and that of your partner if you are working with someone), the course number and section (02 for 11:15, E1 for 4:10). You should have comments throughout your programs describing your variables and any non-obvious Java statements or groups of statements.

All identifiers (class names and variable names) should be meaningful and conform to Java's naming conventions.

Your code should be nicely formatted, with new lines after any `{` or `}`, and indented as done in class examples.