//Charlotte Davies-Kiernan CS1A Chapter 6 P. 370 #7
//
/******************************************************************************
*
* Compute Celsius Conversion
* ____________________________________________________________________________
* This program will convert a temperature from Farenheit to Celsius. Then the
* program will display a table of the Farenheit temperatures 0 through 20 and
* their Celsius equivalents.
*
* Formula used:
* celsius = 5.0/9.0 (farenheit - 32)
* ____________________________________________________________________________
* Input
* farenheit //Temperature in Farenheit that needs to be converted
* Output
* userCelsius //The Farneheit temperature converted into Celsius
* celsiusTemp //The Celsius conversions in the table from the Farenheit degrees 0 through 20
*****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
//Function Prototype
float celsius(float farenheit);
int main() {
//Data Dictionary
float farenheit; //INPUT - Temperature in Farenheit that needs to be converted
float userCelsius; //OUPUT - The Farenheit temperature converted into Celsius
float celsiusTemp; //OUTPUT - The Celsius conversions in the table from the Farenheit degrees 0 through 20
cout << fixed << setprecision(2);
cout << "Enter a Farenheit temperature to convert: " << endl;
cin >> farenheit;
userCelsius = celsius(farenheit);
cout << farenheit << "°F is equal to " << userCelsius << "°C" << endl;
cout << "Farenheit Celsius" << endl;
//Loop through Farenheit values 0 to 20
for (int i = 0; i <= 20; i++){
celsiusTemp = celsius(i);
cout << setw(6) << i << "°F" << setw(14) << celsiusTemp << "°C" << endl;
}
return 0;
}
float celsius(float farenheit){
return (5.0/9.0) * (farenheit - 32.0);
}