#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
double F (double);
double F (double celsius)
{
return((celsius - 32)*.56);
}
double C (double);
double C (double fahrenheight)
{
return((1.8)*fahrenheight + 32);
}
int main()
{
double celsius;
double fahrenheight;
cout << "Fahrenheit equivalents of Celsius temperatures: " << endl;
cout << setw(5) << "Cel" << setw(11) << "Fahr" << setw(6) << "Cel" << setw(11) << "Fahr" << setw(6) << "Cel"
<< setw(11) << "Fahr" << setw(6) << "Cel" << setw(11) << "Fahr" << endl;
for (int i = 1; i <= 26; i++)
{
for (int j = 1; j <= 4; j++)
{
celsius = 25*(j - 1) + i - 1;
if (i == 26 && j != 4)
cout << setw(19) << "\b";
else
cout << setw(5) << celsius << setw(11) << C (celsius) << " ";
if (j == 4)
cout << endl;
}
}
cout << "Celsius equivalents of Fahrenheit temperatures: " << endl;
cout << setw(5) << "Cel" << setw(11) << "Fahr" << setw(6) << "Cel" << setw(11) << "Fahr" << setw(6) << "Cel"
<< setw(11) << "Fahr" << setw(6) << "Cel" << setw(11) << "Fahr" << endl;
for (int i = 1; i <= 46; i++)
{
for (int j = 1; j <= 4; j++)
{
fahrenheight = 45*(j - 1) + i + 31;
if (i == 46 && j != 4)
cout << setw(19) << "\b";
else
cout << setw(5) << setprecision(2) << static_cast< int >(fahrenheight) << setw(11) << F (fahrenheight) << " ";
// setprecision(2) << static_cast< int >() ; added
if (j == 4)
cout << endl;
}
}
return (0);
}
No comments:
Post a Comment