Hello guys,
My prof put a C++ assignment with a coding template. I need to put the code wherever lines he put the comments beside them. (the comment starts with // ) It was blank beside each // comment before.
The goal is to make the output shows:
"Enter a temperature in degrees Celsius: 23.76
23.76 degrees Celsius is 74.768 degrees Fahrenheit."
I did it with a few references but the thing is I think I put the codes in wrong comments. For instance, the code besides the comment "// prompt user to enter a temperature in degrees Celsius " where I should put "cin << temp_C;" there.
And for the comment, "// read in the temperature in degrees Celsius", I actually don't know what to fill besides it. So I just put "cin << temp_C;" because it works. :D
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
using namespace std;
int main()
{
double temp_C; // temperature in degrees Celsius
double temp_F; // temperature in degrees Fahrenheit
cout << "Enter a temperature in degrees Celsius: "; // prompt user to enter a temperature in degrees Celsius
cin >> temp_C; // read in the temperature in degrees Celsius
temp_F = 9.0/5.0 * temp_C + 32; // convert Celsius to Fahrenheit
cout << temp_C << " degrees Celcius is " << temp_F << " degrees Fahrenheit. " << endl; // display temperature in Celsius and Fahrenheit
return 0;
}
|
Originally, the assignment is the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#include <iostream>
using namespace std;
int main()
{
double temp_C; // temperature in degrees Celsius
// prompt user to enter a temperature in degrees Celsius
cout << "Enter a temperature in degrees Celsius: ";
// read in the temperature in degrees Celsius
// convert Celsius to Fahrenheit
// display temperature in Celsius and Fahrenheit
return 0;
}
|
I hope you guy can help me out. Thank you.