Click here to Skip to main content
15,906,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm a new pupil of C++ programming.
This is my practice code.
But I have a error on bold text(REGULAR_PAY).
What problem is on that!? I wonder...
C++
 #include <iostream>
 using namespace std;
 #define REGULAR_HOUR 125;
 #define REGULAR_PAY 5580;
 #define OVER_PAY 6500;

int main()
{
	int hour;
	int grossPay;
	int taxRate;
	cout << "Input the worked hour of this month: ";
	cin >> hour;
	if (hour<=125)	{
		grossPay = hour*REGULAR_PAY;
	}
	else
		grossPay = REGULAR_HOUR*REGULAR_PAY + (hour-125)*OVER_PAY;
	if	(grossPay<900000)
		taxRate=1;
	else if (grossPay<=1500000)
		taxRate=2;
	else if (grossPay<=2000000)
		taxRate=8;
	else if (grossPay>2000000)
		taxRate=10;
	cout << "Gross Pay = KRW "<<grossPay<<endl
		<< "Income Tax Rate = "<<taxRate<<"%"<<endl;


}
Posted
Updated 24-Aug-15 20:45pm
v2
Comments
chandanadhikari 25-Aug-15 2:58am    
well,
it is time to stop wondering and start learning debugging !!
If you are using Visual Studio IDE then you can check this link:
https://msdn.microsoft.com/en-us/library/bb384844.aspx

if you are using some other IDE then google out how to use its debugger .

also please try to be more precise with your question.
for example include details like whether you are getting some error message or the application crashes etc.

1 solution

Quote:
#define REGULAR_HOUR 125;
#define REGULAR_PAY 5580;
#define OVER_PAY 6500;
You should remove the trailing semicolons in preprocessor defines.
Better, you should get rid of preprocessor defines and use enum instead, e.g.
C++
enum
{
  REGULAR_HOUR = 125,
  REGULAR_PAY = 5580,
  OVER_PAY =6500
};


If you have a modern compiler you may also have a look at scoped enumerations[^].
 
Share this answer
 
Comments
Member 11933200 25-Aug-15 3:17am    
Oh, semicolons are problems!! Thank you!
I changed to enum, it succeeded!
Yeah, What the differences are #define , const int , enum !?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900