0
How to write program that 'Convert Fahrenheit to Kelvin' ?
Write a program to convert a temperature in degrees Fahrenheit to the kelvin scale. Data Requirements Problem Input int fahrenheit /* temperature in degrees Fahrenheit */ Problem Output double kelvin /* temperature on the kelvin scale */ Relevant Formula kelvin = 5/9 (fahrenheit − 32) + 273.15
3 Réponses
+ 2
double FtoK(int f) {
return ((double)f-32.0)*5.0/9.0+273.15;
}
+ 2
That's a function, which can be called in the following way:
http://code.sololearn.com/clUd0UKVfsjE/#
#include <iostream>
using namespace std;
double convertToKelvin(double f) {
return (f - 32) * 5 / 9 + 273.15;
}
int main()
{
double fahrenheit = 22.32;
double result = convertToKelvin(fahrenheit);
cout << fahrenheit << " fahrenheit = " << result << " kelvin." << endl;
return 0;
}
- 1
this doesn't make sense much