// Torrez, Elaine CS1A Chapter 5 P. 296, #12
/******************************************************************************************
*
* Celsisus to Fahrenheit Table
*
* --------------------------------------------------------------------------------
* This program displays a table showing the Celsius temperatures 0 through 20
* and their Fahrenheit equivalents. The conversion formula used is:
*
* Fahrenheit = (9.0 / 5.0) * Celsius + 32
*
* The program uses a for loop to perform and display each conversion.
* --------------------------------------------------------------------------------
*
* INPUT
* celsius : Celsius temperature (loop variable, 0 through 20)
*
* OUTPUT
* fahrenheit : Temperature converted from Celsius to Fahrenheit
*
*******************************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
double celsius; // INPUT - Celsius temperature (0–20)
double fahrenheit; // OUTPUT - Converted Fahrenheit temperature
cout << "Celsius\tFahrenheit\n";
cout << "-------------------\n";
// Loop from 0 through 20 Celsius
for (celsius = 0; celsius <= 20; celsius++)
{
fahrenheit = (9.0 / 5.0) * celsius + 32;
cout << fixed << setprecision(1);
cout << setw(5) << celsius << "\t" << setw(8) << fahrenheit << endl;
}
return 0;
}