help with code

im trying to develope a program that determines gross pay not including overtime. Pay rate must be between $1-$100

The tax rates are as follows:
>= 2500.00 then Tax Rate equals 0.45

>= 2000.00 then Tax Rate equals 0.40

>= 1500.00 then Tax Rate equals 0.35

>= 1000.00 then Tax Rate equals 0.30

Less than 1000.00 has a Tax Rate equal to 0.25

the input screen should look like this
Enter the following data:
Hours Worked: (Number)
Hourly Rate: (Number)

the output screen should look like this
Hours Worked : (number)
Hourly Rate: (number)
Tax Rate: (number)
Gross Pay: (number)
Taxes: (number)
Net Pay: (number)


code:
#include <iostream>
using namespace std;

int main()
{
double x,y,taxrate,grosspay,tax,netpay

cout << "enter hours worked ";
cin >> x;

cout << "enter hourly rate ";
cin >> y;

grosspay=x*y;
while(grosspay>=0){
if (2000<grosspay>=2500)
taxrate=.45
else (1500<grosspay>=2000)
taxrate=.40
else (1000<grosspay>=1500)
taxrate=.35
if(grosspay=1000)
taxrate=.30
else(0<grosspay<1000)
taxrate=.30;
}

tax=grosspay*taxrate;
netpay=grosspay-tax;

cout<<"hours worked:" return x;
cout<<"hourly rate:" return y;
cout<<"tax rate:" return taxrate;
cout<<"gross pay:" return grosspay;
cout<<"net pay:" return netpay;



system("pause");
}
end code:
A couple things:
1. You are missing a lot of ; at the end of your lines.
2. I don't think you need the while loop.
3. The syntax for if (2000<grosspay>=2500) is if (2000 <= grosspay && grosspay < 2500) , I change the boundaries to match what you said above. Check the other tax rates.
4. Look at you if () else if () structure.
5. Syntax for cout of a variable is cout << "Hours worked: " << x << endl;, not return.
Hope this helps
Last edited on
Wow this is rough. Are you taking a class for C++? Or reading a book/tutorial? You really need to learn the absolute basics first
Topic archived. No new replies allowed.