CS431 - Homework #1
/*******************************
Name: Thomas Heffron (tehqnf@umkc.edu)
Section: CS431 NET
Program: Assignment #1
Due Date: Sept. 10, 2002
Desc: Write a small
Linux program to translate
temperature from C to F.
Inputs: float value as deg. C
Continue until Ctrl-D
Outputs: Float value as deg. F
Note when end of program
********************************/
#include <iostream>
float toFahr( float Cels ) // External function to calculate deg F
{
return ((9.0/5.0) * Cels) + 32.0;
}
int main()
{
// Type Declarations
float Celsius, Fahrenheit;
// Quick Display of Usage
cout << "*** This process will translate your" << endl;
cout << "*** numerical input in to degrees F." << endl << endl;
cout << "*** Type CTRL-D when finished." << endl << endl;
// Prompt to input
cout << "Enter degrees C: ";
// Loop until CTRL-D is pressed
while ( (! cin.eof() ) && cin >> Celsius)
{
Fahrenheit = toFahr(Celsius); // Function call
// Diaplay results and prompt again
cout << Celsius << " degrees C = " << Fahrenheit << " degrees
F" << endl << endl;
cout << "Enter degrees C: ";
}
// Notify at end of program
cout << endl << endl << "*** END OF PROGRAM ***" << endl <<
endl;
}