CIS-2271 Homework #3: Loops

Due: Thursday, September 18, 2014

Read Chapter 4 in the text.

  1. Write a program that computes a table of Fahrenheit to Celsius conversions. The program should ask the user to enter a start temperature, an end temperature, and a step size. It should then print a table where the first column is degrees Fahrenheit and the second column is the corresponding degrees Celsius. A typical run of the program might look like

    Start (degrees F): 0.0
    End   (degrees F): 100.0
    Step  (degrees F): 5.0
    
    degrees F    degrees C
    ---------    ---------
          0.0        -17.8
          5.0        -15.0
         10.0        -12.2
         15.0         -9.4
         20.0         -6.7
         25.0         -3.9
         30.0         -1.1
         35.0          1.7
         40.0          4.4
         45.0          7.2
         50.0         10.0
         55.0         12.8
         60.0         15.6
         65.0         18.3
         70.0         21.1
         75.0         23.9
         80.0         26.7
         85.0         29.4
         90.0         32.2
         95.0         35.0
        100.0         37.8
          

    Be sure the output is formatted nicely (it doesn't have to be exactly like above, however). The formula for computing Celsius from Fahrenheit is

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

    Caution: Be sure to do all computations using type double!

    In addition your program should do some input validation. It should verify that the end temperature is greater than the start temperature and that there is at least one step between the two temperatures. Print an appropriate error message if the input is not valid.


Last Revised: 2014-09-11
© Copyright 2014 by Peter C. Chapin <PChapin@vtc.vsc.edu>