Small problem with adding a decimal to an answer

Hello all,
The program works fine, except my instructor wants a decimal point at the end of the Celcius conversion. For example:

Enter the temperature in degrees Fahrenheit: 212
The corresponding Celcius temperature is: 100.0

Press any key....

Can someone help me out with this? I know there is something missing with Celcius - I'm not sure what I'm supposed to do here. I just spent an hour and a half of googling how to fix this with no answers. Keep in mind that what I have below so far is what we've learned and I'm not sure how commands like "Float", or anything that isn't there is going to fly with the instructor.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "stdafx.h"
#include <iostream>
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	double F = 0;
	
		cout << "Enter the temperature in degrees Fahrenheit: ";
		cin >> F;
		cout << endl;
		cout << endl;

		cout << "The corresponding Celcius temperature is: " << (F - 32) * 5.0 / 9.0 = C << endl;
		
		cout << endl;

		system("pause");
		


	return 0;
Try this

put this at top
#include <iomanip>

cout << "Enter the temperature in degrees Fahrenheit: ";
cin >> F;
cout << endl;
cout << endl;
cout << setprecision(1) << fixed;
cout << "The corresponding Celcius temperature is: " << (F - 32) * 5.0 / 9.0 = C << endl;
cout << endl;
I tried what you said.

double F = 0.0;
cout << "Enter the temperature in degrees Fahrenheit: ";
cin >> F;
cout << endl;
cout << endl;
cout << setprecision(1) << fixed;
cout << "The corresponding Celcius temperature is: " << (F - 32) * 5.0 / 9.0 = C << endl;
cout << endl;

Now the C in the equation 5.0 / 9.0 = C is flagged by the system as undefined.
When I added the C (double C = 0.0;) nothing happened and the C is still undefined.
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	double F = 0;
	
		cout << "Enter the temperature in degrees Fahrenheit: ";
		cin >> F;
		cout << std::fixed; // As previous
		
		cout << "The corresponding Celcius temperature is: " 
		     << std::setprecision(1) // As previous
	         << (F - 32) * 5.0 / 9.0 << endl; // not  (F - 32) * 5.0 / 9.0 = C 
	         
	return 0;
}
Topic archived. No new replies allowed.