Source Code for Lab #3


/*
   lab03.cpp. This program reads a temperature in Fahrenheit
   and calculates the equivalent Celsius temperature.
 
   It then reads a temperature in Celsius
   and calculates the equivalent Fahrenheit temperature.
*/ 
   
#include <iostream>
using namespace std ;

int main(void)
{
        /* 
           The variables Fahrenheit and Celsius below are int's. DON'T CHANGE
           THEM to anything else.  In particular, do NOT change them into
           double or float.
        */
   int Fahrenheit,   // temperature in Fahrenheit 
       Celsius;      // temperature in Celsius    

   cout << "\nThis program converts a temperature in" << endl ;
   cout << "Fahrenheit to Celsius and vice versa." << endl ;
   cout << "All measurements are in whole numbers." << endl  << endl ;

   cout << "Please enter an integer Fahrenheit temperature:  ";
   cin  >> Fahrenheit;

/*
    The assignment statement below computes the (approximate) Celsius
    temperature corresponding to the Fahrenheit temperature, and stores the
    value into the variable called Celsius.

    Fill in the formula needed on the Right Hand Side below.

*/
   
   Celsius =    ;
   
   cout << Fahrenheit << " degrees Fahrenheit equals about " 
        << Celsius << " degrees Celsius" << endl << endl;

   return 0;
}