int main() {
int num1, num2, sum;
cout << "Please enter first number: ";
cin >> num1;
cout << "Please enter second number: ";
cin >> num2;
sum = num1 + num2;
cout << "The sum is " << sum << endl;
return 0;
}
I am supposed to use this sample program to calculate the temperature conversion like
°C = 5/9 (°F - 32)
To find degrees Fahrenheit when you know the Celsius temperature use this equation:
°F = 9/5 °C + 32
To find degrees in Kelvin when you know the Celsius temperature use this equation:
°K = °C + 273.15
To find degrees in Rankine when you know the Fahrenheit temperature use this equation:
°R = °F + 459.67
It looks like the input should be in farenheit and produce 4 outputs of different concersion of temps.
If ayone can help me with this I'd appreciate it very much.
2007-02-14
11:54:03
·
4 answers
·
asked by
Anonymous
in
Computers & Internet
➔ Programming & Design
I am supposed to use this sample
and change the variables and stuff to make the conversion happen. This is what i did so far
int main() {
double fahrenheit, celsius, kelvin, rankine;
// display initial program identification
cout << "Simple C Program - Don Retzlaff "
<< "donr@unt.edu" << endl << endl;
// prompt the user for input
cout << "Please enter temp: ";
cin >> fahrenheit;
celsius = (5/9)*(fahrenheit - 32);
cout << "the temp is " << celsius << endl;
fahrenheit = 9/5 *(celsius + 32);
cout << "the temp is " << fahrenheit << endl;
kelvin = celsius + 273.15;
cout << "the temp is " << kelvin << endl;
rankine = fahrenheit + 459.67;
cout << "the temp is " << rankine << endl;
return 0;
}
This compiles right, but only output I get is the constants. The input is not calculated for some reason.
2007-02-14
12:10:30 ·
update #1