//Ryan Shahriyarpour CS1A Carl Argila CH6 HW Q:7
//
/*****************************************************************************
*
* Fahrenheit to Celsius Table
*
*********************
*
* This program displays a table of Fahrenheit temperatures from 0 to 20 and
* their Celsius equivalents. The function celsius does the conversion:
* C = (5/9) * (F - 32)
*
* INPUT
* None (fixed values used)
*
* OUTPUT
* Table showing Fahrenheit temperatures and their Celsius equivalents
*
****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
// Function prototype
double celsius(double fahrenheit);
int main()
{
cout << "Fahrenheit\t\tCelsius\n";
cout << "---------------------------------------\n";
// Display temperatures from 0 to 20 Fahrenheit
for (int fahrenheit = 0; fahrenheit <= 20; fahrenheit++)
{
cout << fahrenheit << "\t\t\t" << fixed << setprecision(1)
<< celsius(fahrenheit) << endl;
}
return 0;
}
// Accepts a Fahrenheit temperature and returns it in Celsius
// (5.0/9.0 is used instead of 5/9 to avoid integer division)
double celsius(double fahrenheit)
{
return (5.0 / 9.0) * (fahrenheit - 32.0);
}