Code Studio: Temperature Converter
Use R as a calculator, as in Practice: Calculator, and store results in well-named variables.
The program reads a temperature in degrees Fahrenheit. Finish it so that it prints the same temperature in Celsius and in Kelvin:
- Celsius = (Fahrenheit − 32) × 5 / 9
- Kelvin = Celsius + 273.15
Round both to 2 decimal places with round(x, 2) and print them exactly like this, for an input of 212:
Celsius: 100 Kelvin: 373.15
Try it: type a number in the Input tab and press Run. When you think it's right, press Check to run the tests, then Submit.
Watch the order of operations: what does fahrenheit - 32 * 5 / 9 calculate?
Use R as a calculator, as in Practice: Calculator, and store results in well-named variables.
The program reads a temperature in degrees Fahrenheit. Finish it so that it prints the same temperature in Celsius and in Kelvin:
- Celsius = (Fahrenheit − 32) × 5 / 9
- Kelvin = Celsius + 273.15
Round both to 2 decimal places with round(x, 2) and print them exactly like this, for an input of 212:
Celsius: 100 Kelvin: 373.15
Try it: type a number in the Input tab and press Run. When you think it's right, press Check to run the tests, then Submit.
Watch the order of operations: what does fahrenheit - 32 * 5 / 9 calculate?