I am working on a temp chart conversion. We have the the conversion from Celsius to Fahreneheit rounded to whole numbers but the conversion from Fahrenheit to Celsius keep putting decimals out. I need it to output whole numbers.
Here is the code:
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
int main()
{
ofstream outFile ("ass3.run");
const int LOWER = 0;
const int UPPER = 400;
const int STEP = 10;
int FARR = LOWER;
float Celsius;
/* Print table heading */
outFile <<setw(19);
outFile << "Fahrenheit";
outFile <<setw(12);
outFile << "Celsius";
outFile <<setw(20);
outFile << endl;
/* print table from LOWER to UPPER */
for (FARR = LOWER ; FARR <= UPPER ; FARR += STEP)
{
int Fahrenheit (int);
outFile <<setw(15);
outFile << FARR;
Celsius = (float(5)/float(9)) * (FARR - 32);
outFile <<setw(15);
outFile << Celsius;
outFile <<setw(15);
outFile <<endl;
}
const int RETARD =0;
const int STUPID =200;
const int ASS = 5;
int CELS = RETARD;
float FAR;
outFile <<setw(19);
outFile <<endl<<endl;
outFile << "Celsius";
outFile <<setw(15);
outFile << "Fahrenheit";
outFile <<setw(20);
outFile << endl;
for (CELS = RETARD; CELS <= STUPID ; CELS += ASS)
{
int Celsius (int);
outFile <<setw(15);
outFile << CELS;
FAR = (float(9)/float(5) * (CELS) + 32);
outFile <<setw(15);
outFile << FAR;
outFile <<setw(15);
outFile <<endl;
}
return 0;
}[CODE]
This is the output we keep getting:
Fahrenheit Celsius
0 -17.7778
10 -12.2222
20 -6.66667
30 -1.11111
40 4.44444
50 10
60 15.5556
70 21.1111
80 26.6667
90 32.2222
100 37.7778
110 43.3333
120 48.8889
130 54.4444
140 60
150 65.5556
160 71.1111
170 76.6667
180 82.2222
190 87.7778
200 93.3333
210 98.8889
220 104.444
230 110
240 115.556
250 121.111
260 126.667
270 132.222
280 137.778
290 143.333
300 148.889
310 154.444
320 160
330 165.556
340 171.111
350 176.667
360 182.222
370 187.778
380 193.333
390 198.889
400 204.444
Celsius Fahrenheit
0 32
5 41
10 50
15 59
20 68
25 77
30 86
35 95
40 104
45 113
50 122