Can't run the program

I am new learner towards C++ and is doing my tutorial question. I simply dunno what is gong on with my program. must be some stupid mistakes I have done. please help me.

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
66
67
68
69
  #include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
	
int main()
	
{
	double basic;
	double quantum; 
	double bonus;
	double total;

	cout << "Please enter basic salary";
	cin >> basic;	

	if (basic <= 800)
{
	quantum = 500;
		bonus = 0;
		total = basic + quantum + bonus;

cout << "Basic: $"<<basic<<endl;
cout << "Quantum: $"<<quantum<<endl;
cout << "Bonus: $" <<bonus<<endl;
cout << "Total: $" << total<<endl;
	}
	else if (801 <= basic && 
		basic <=1500)
	{
		quantum = basic*0.05;
		bonus = 150;
		total = basic + quantum + bonus;

cout << "Basic: $"<<basic<<endl;
cout << "Quantum: $"<<quantum<<endl;
cout << "Bonus: $" <<bonus<<endl;
cout << "Total: $" << total<<endl;
	}
	else if (1501 <= basic && basic <=3500)
	{
		quantum = basic*0.07;
		bonus = 70;
		total = basic + quantum + bonus;

cout << "Basic: $"<<basic<<endl;
cout << "Quantum: $"<<quantum<<endl;
cout << "Bonus: $" <<bonus<<endl;
cout << "Total: $" << total<<endl;
	}
	
	else (basic >= 3501);

	{
		quantum = basic*0.02;
		bonus = 0;
		total = basic + quantum + bonus;

cout << "Basic: $"<<basic<<endl;
cout << "Quantum: $"<<quantum<<endl;
cout << "Bonus: $" <<bonus<<endl;
cout << "Total: $" << total<<endl;
	}


cin.ignore();
cin.ignore();
}
// main 
I simply dunno what is gong on with my program. must be some stupid mistakes I have done. please help me.

We don't know what's going on with your program either, since you've failed to say why you believe it is not working as you intended.

Question, though. If you enter 800.5 for basic, which if/else body is entered?

You have an empty statement for the body of the else on line 52. Remove the semi-colon.

Since 4 lines in each if/else body are exactly the same, is there any way you can keep from repeating them?
oh yes, 800 - 801 is not covered. the means I should be using int basic instead of double basic. anyway

is there any way I can post img file in here?

I maintained the double and remove the ;
and tried the the prog and got the error code as follow

1>c:\users\.....\cbhaq2.cpp(54): error C2143: syntax error : missing ';' before '{'

what is the meaning?
Last edited on
I would guess it means that else (basic >=3501) isn't a valid code construct. An else is not governed by a condition. Either make it else if (basic >=3501) or just else.
Thanks, resolved the syntax error, an another fatal error occurs.

fatal error LNK1169: one or more multiply defined symbols found

omg, I am really a noob.
I have resolved it. it is due to have two source file with one project sharing the same main().

I move the source file to another project and has successful compile it. Thanks for your help
Topic archived. No new replies allowed.