Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/cs103/hw-variables/degrees by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
This program is supposed to read a temperature in degrees Fahrenheit,
and output the corresponding temperature in degrees Celsius, using the formula
$$C = 5 \times \frac{F-32}{9}.$$
For example, when the input $F$ is 41, the output $C$ should be 5.
There's something missing, which is causing the program to give an incorrect 
answer. Debug it.
Engine
Template / Reference solution
 
#include <iostream>
using namespace std;
int main() {
   double F;
   cin >> F; // read input, degrees Fahrenheit
   double C = \[ REDACTED \show:5 * F - 32 / 9]\;
   cout << C; // print the output, degrees Celsius
   return 0;
}
C++ test suite
json list of stdin/args tests
e.g. [{"stdin":"hi", "args":["4", "5"]},
{"stdin":"noargs"}]

to just run once with no input use [{}]
 
[
   {"stdin": "41"},
   {"stdin": "50"},
   {"stdin": "77"},
   {"stdin": "-10"},
   {"stdin": "100"},
   {"stdin": "-32"},
   {"stdin": "-40"}
]


Optional properties:

Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.