Computer Science 202
Introduction to Programming

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

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.

A few additional guidelines:

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.

Submitting Your Work

Before 11:59 PM, Wednesday, October 31, 2012, submit your Visual Logic flowchart and your Java program to Blackboard for grading. Please upload only your saved flowchart (TempConvert.vls) and Java source file - the one with the .java file extension, not the .class, .ctxt, package.bluej or README files).


This assignment is worth 25 points, which are distributed as follows:

> FeatureValueScore
Flowchart inputs 1
Flowchart For loop 2
Flowchart temperature conversion 2
Flowchart output 1
Flowchart correct series of temperatures to convert 2
Java inputs 1
Java for loop 2
Java temperature conversion 2
Java output (including proper formatting) 2
Java correct series of temperatures to convert 2
Java defining and using required named constant 1
Using correct filenames 1
Comments (in Java only) 3
Naming conventions (in both) 2
Formatting (in Java only) 1
Bonus up to 4
Total 25