Compile Errors, Review my Code

I just reconstructed my new code and am having trouble. When I try to compile it I keep getting an error message. At the end of the program something is wrong, but I can't figure it out.

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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <cmath> 
#include <string>

using namespace std;

int main ()
{
	int weight;
	string Planet;
	char signal; //for when the program is prompted to terminate	
	
	
	{
		do {
			cout << "Please enter a weight between 0 to 1000 pounds rounded to the nearest whole number" << endl; //Prompts user to input valid weight
			cin >> weight;
			if (weight >= 0 && weight <= 1000) //Uses the condition that the weights have to be between 0 and 1000 to continue
				
			{
				cout << "Please enter a planet name from the following list." << endl;
				cout << "Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune" << endl;
				
				cout.precision(2)
				if(Planet== "Mercury"){
					cout << "The weight on Mercury is " << (weight*0.4155)<< endl;
				}
				else if(Planet== "Venus"){
					cout << "The weight on Venus is " << (weight*0.8975)<< endl;
				}
				else if(Planet== "Earth"){
					cout << "The weight on Earth is " << (weight*1.0)<< endl;
				}
				else if(Planet== "Mars"){
					cout << "The weight on Mars is " << (weight*0.3507)<< endl;
				}
				else if(Planet== "Jupiter"){
					cout << "The weight on Jupiter is " << (weight*2.5374)<< endl;
				}
				else if(Planet== "Saturn"){
					cout << "The weight on Saturn is " << (weight*1.0677)<< endl;
				}
				else if(Planet== "Uranus"){
					cout << "The weight on Uranus is " << (weight*0.8947)<< endl;
				}
				else if(Planet== "Neptune"){
					cout << "The weight on Neptune is " << (weight*1.1794)<< endl;
								
				else
				{
					cout << "Press c to input a new weight or q to terminate the program" << endl; //terminate or continue prompt
					cin >> signal;
				}
				
			}
			else if (weight <= 0 || weight >= 1000) //When user has not input a valid weight
				cout << "Please enter in a weight between 0 and 1000" << endl;
		} while (signal != 'q'); //Keeps repeating the program process until user inputs correct data until user presses 'q'
			
	}		
	if (signal = 'q') // When q is pressed the program terminates
		cout << "The program has ended, Have a nice day." << endl;
	
	return 0;
}
Last edited on
@Line 61: Wrong equals. :)

What is this error message that it's giving you? And... Out of curiosity, why do you have an else on line 49?

After closer inspection, there's something missing on lines 48 and 24.

-Albatross
Last edited on
finally got it. That else statement wasn't needed.

Also I realized I need a ";" at the end of line 24 and an another "}" on line 27
Topic archived. No new replies allowed.