What can I do to make this functional?

What am I missing to get this farenheit to celsius program running? I am almost there but I keep getting this errors.

37 5 \farenheit1.cpp [Error] stray '\226' in program
\farenheit1.cpp In function 'int main()':
37 29 \farenheit1.cpp [Error] expected ')' before numeric constant
28 \Makefile.win recipe for target 'farenheit1.o' failed

Also, how would I do these two things?
1. Add in an if statement to check the input from the user. If input is correct continue on with the program, if not correct ask user for a new value

2. Add repetition after the solution is displayed to see if the user wants to continue with the program or quit.

Thank you in advance for any help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>

 

using std::cout;

using std::cin;

using std::endl;                      

 

int main()

{  

    //Variables                          

    float Celsius;    //represents the temperature in Celsius degrees

    float Fahrenheit; //represents the converted temperature in Fahrenheit degrees

 

    //Ask for the temperature in Fahrenheit temp

    cout << "Enter Fahrenheit temperature: ";

    cin >> Fahrenheit;

 

    //Formula to convert degrees in Fahrenheit to Celsius degrees

    //Important note: floating point literals need to have the '.0' in order to display the output properly

    Celsius = (Fahrenheit – 32.0) * 5.0/9.0;

 

    //Print the converted temperature to the console

    cout << "Celsius = " << Celsius << endl;                           

}
The "stray" error is from your minus sign not being a minus sign on line 37. Try retyping the minus sign in a code editor (not something like Word, if that is what you are using, but maybe something like Visual Studio or Eclipse or vim or notepad++) then recompiling.

1. Check this link: http://www.cplusplus.com/forum/beginner/14117/. In efklebba's example, you may be able to replace the int a with float a, although I admit I haven't tried it.
2. Wrap your entire main function with a do-while loop. At the end of the loop, use a cout/cin statement to ask the user if he or she wants to continue. Save that input into a boolean variable, and make that the condition in your do-while loop.
Last edited on
Topic archived. No new replies allowed.