problem with "if" statement!

I was trying to write a program that calculates the tax of an item (state,city & luxury tax and add them to the price sale to output the amount due.

the program have to determine if the item is a luxury item by itself.
if
the only problem I am facing is with my "if" statement

1
2
if sale_price < 49999 luxuray_tax = 0;
if sale_price > 49999 luxuray_tax = sale_price * 0.1;


I am using code::blocks and its saying:

error: expected '(' before 'sale_price'



here is my full code:
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
  # include <iostream>

using namespace std;

int main()
{
 float sale_price;
 float state_sale_tax;
 float city_sale_tax;
 float luxury_sale_tax;
 float total_tax;
 float total_amount_due;

    cout << "This is a program that calculates the sale price of an ";
    cout << "item and adds the tax of city and state and output the amount due" << endl;

    cout << "Please enter the sale price of your item" << endl;
    cin >> sale_price;

        state_sale_tax = sale_price * 0.04;
        city_sale_tax = sale_price * 0.015;

    if sale_price < 49999 luxuray_tax = 0;
    if sale_price > 49999 luxuray_tax = sale_price * 0.1;


    cout << "State Tax due is " << state_sale_tax << endl;
    cout << "City Tax due is " << city_sale_tax << endl;
    cout << "Luxury Tax due is " << luxury_sale_tax << endl;

    total_tax = state_sale_tax + city_sale_tax + luxury_sale_tax;
    cout << "Total Tax due is " << total_tax << endl;

    total_amount_due = sale_price + total_tax;
    cout << "Total amount due is " << total_amount_due << endl;

    cout << "thank you for using my program, have a nice day " << endl;

    return 0;
}



Thank you in advance <3
You should go back to your textbook, and check the syntax for an "if" statement. You're missing something important.
closed account (iAk3T05o)
Yes. It should be something like this:
1
2
3
4
5
6
7
8
if (sale_price <= 49999)
{
luxury_tax = 0; //not luxuray_tax
}
else if (sale_price >= 49999)
{
luxury_tax = sale_price  * 0.1;
}
Last edited on
thank you very much for your help and for pointing out my typo!
Topic archived. No new replies allowed.