So far I have gotten the temperature conversions from fahrenehit to celsius to print out properly. But when it comes to Celsius to Fahrenehit it prints out 65 constantly as well as 15.56 fahrenheit constantly. Our teacher mentioned something about Pass By Reference but im not sure were to use it. Any help is appreciated.
Shawn
Here is the CODE
Code:
#include <iostream>
using namespace std;
int main()
{
cout.precision(2);
cout.setf(ios::fixed);
const int LOWER = 0;
const int UPPER = 60;
const int STEP = 5;
int fahr = LOWER;
double celsius = 0;
/* Print table heading */
cout.width(19);
cout << "Fahrenheit";
cout.width(12);
cout << "Celsius";
cout.width(20);
cout << endl;
/* print table from LOWER to UPPER */
for (fahr = LOWER ; fahr <= UPPER ; fahr += STEP)
{
cout.width(15);
cout << fahr;
celsius = (double(5)/9) * (fahr - 32);
cout.width(15);
cout << celsius;
cout.width(15);
cout <<endl;
}
const int LOWER1 =0;
const int UPPER1 =60;
const int STEP1 =10;
int cels = LOWER1;
double fahrenheit = 0;
cout.width(17);
cout<<endl <<endl;
cout << "Celsius";
cout.width(15);
cout << "Fahrenheit";
cout.width(20);
cout << endl;
for (cels = LOWER1; cels <= UPPER1 ; cels += STEP1)
{
cout.width(15);
cout << fahr;
fahrenheit = (double(9)/5 * cels) + 32;
cout.width(15);
cout << celsius;
cout.width(15);
cout <<endl;
}
return 0;
}