C++ Assignment 6
Temperature Conversion program using redirection

Your assignment is to write a program that reads in three temperatures in Fahrenheit, converts them to Celsius and displays the result. The formula to convert Fahreheit to Celsius is shown below. WATCH OUT FOR INTEGER ARTIHMETIC!

Celsius = (Fahrenheit – 32)(5/9)

The input and output will be decimal numbers. The program will use redirection to read the input from the computer's disk, rather than from the keyboard. Since there is no direct user input your program does not need a prompt or to echo the input. Don't reinvent the wheel. This program is very similar to your previous assignments.

The program output should appear similar to the following:


C:\>cd Documents and Settings\c1\My Documents
C:\Documents and Settings\c1\My Documents>TempConv.exe<data.txt

Fahrenheit value -      212
Celsius value -         100

Fahrenheit value -      32
Celsius value -         0

Fahrenheit value -      -40
Celsius value -         -40

Steps to completing this assignment:

  1. Write a program like you did in Assignment 5, except that this program should use the Fahrenheit to Celsius conversion shown above. Test your program thoroughly to make sure it works. Look at the output shown above for test values.
  2. Open Notepad. You do this by selecting Start | Programs | Accessories | Notepad. Notepad is a very simple text editor and is perfect for making our data file. Type the following three numbers, each separated by a space: 212 32 –40. Save the file to the My Documents folder with the name data. Close Notepad.
  3. Go to the command prompt. You do this by selecting Start | Programs | Accessories | Command Prompt. Enter the following after the C:\> (if your user id is not c1, then use c2 or c3).

    cd Documents and Settings\c1\My Documents

  4. Then type TempConv.exe<data.txt where TempConv is the name you gave your program. If you gave your program a different name than TempConv use that name.
  5. Your program should run using the data in the data file. Type exit
  6. Use Hungarian notation, constants, whitespace, indent code in curly braces and all the elements of good style that we have learned so far
  7. Your program should have 3 functions plus main(). To process the numbers, call the functions three times.
  8. Include comments that show sample output, and your name, class and assignment #. Include in your sample output the line that shows you used redirection.
  9. Attach the .cpp to email and send it to mrsimon@lycos.com
  10. Don't forget to put your name, class and assignment # on the subject line.