Compiler error any feedback helps

New to C++ and i am having a little trouble with this problem I feel like i'm declaring the variables wrong but do not know what exactly. ANY FEEDBACK HELPS.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

int main()
int annualincome, ;
int taxrate=10%, ;
float finalpay ;


{
    cout<<("Hello please enter your annual income" annualincome);
    cin>>annualincome;
    cout<<"the tax rate is 10%"
    cout<<(annualincome-taxrate=finalpay);
    cout<<("your final pay is"finalpay);

    return 0;
}
btw problem is to calculate final income after tax rate deduction
{ is wrong. move it just below main:
int main()
{
int x; //etc

commas are wrong too:
int x;
double d; //correct

int x,y,z; //correct

int x, ; //incorrect.

10% is incorrect.
int taxrate = 10; //correct.
double taxrate = 0.1; //better?

cout is wrong. cout << "words"; //correct
cout << ("words" blah) ; //incorrect.


fixed with best guess at what you wanted: (note no () on cout, note <<variable<< in cout, note 1-taxrate to get 90% of original value which is same as original value - 10% etc, note
use of double to do the tax, etc...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main()
{
int annualincome ;
double taxrate= 0.10 ;
float finalpay ;

    cout<<"Hello please enter your annual income\n";
    cin>>annualincome;
    cout<<"the tax rate is 10%\n";
    finalpay = annualincome* (1.0-taxrate);
    cout<<"your final pay is " << finalpay<< endl;

    return 0;
}




% is the integer remainder in c++ (try it: cout << 11%10 <<endl; ) . percentages are just done as per math, as a decimal where 1.0 = 100%, and remember to deal with inverted percentages ... 10% tax is 10% money paid, 90% kept, so the answer is 90% of the original, which is 0.9 * the value... right?
Last edited on
Each token printed by cout needs to separated by <<
So don't do cout<<("your final pay is"finalpay);
do cout << "your final pay is " << finalpay;


cout<<(annualincome-taxrate=finalpay);
This doesn't make sense, for three reasons.
(1) Don't make assignments in the middle of a statement line that, it's very error-prone.
(2) It's the left-hand side that is assign to. finalpay should be on the left.
(3) If it's a tax rate as a percentage, and you're trying to calculate the income w/ taxes deducted, then you should be multiplying by the income and subtracting that.
finalpay = annualincome - taxrate * annualincome; // where taxrate = 0.10 as jonnin said
Last edited on
thanks for the info guys really clarified everything and program runs. my teacher would have tried to help by giving a lecture about pseudocode
Topic archived. No new replies allowed.