-1

I am having trouble writing a "if" "else" statement to this what I came up with but it will not execute when I run the program.

#include <iostream>
using namespace std;
int main()
{
    double  vehicle_price, options_price, new_result, end_solution, sales_tax_region, v8_price, sales_tax;
    double region_0, region_1, region_2;

    // This where the sales person will ask the customer if a v8 is desired.
    cout << "vehicle_price:$"     ;
    cin >>  vehicle_price       ;
    cout <<  "options_price:$"  ;
    cin >> options_price       ;

    // At this time the customer would be asked which region they live in.

    //  enter 6.5 or 7.0 to indicate if region_1 or region_2 is where they live

    cout << "v8_price:$"   ;
    cin >> v8_price     ;
    cout << "sales_tax_region:"      ;
    cin >> sales_tax_region         ;

    // At this point the price of the v8 would be entered if it is required. 

    if (region_1 <= 500.00)
    {
        sales_tax= region_1 *.65; 
    }
    if (region_2 <= 550.0) 
    {
        sales_tax_region= region_2 * .70;
    }
    else
    {   
        if (region_0 <= 0.0);
    }
    sales_tax_region= region_1 * .65;
    {
    }
    new_result= (options_price + vehicle_price+ v8_price)*(sales_tax_region/100) ;
    end_solution = (new_result + options_price + vehicle_price);
    cout << "Total_price_of_the_vehicle:$"  << end_solution << endl ;

    return 0;
}

This is the requirements that I am using Use an “if-else” structure to determine which V8 price to use. Use another “if-else” structure to determine the sales tax value to select based on the region code.

I am totally lost on the "if" "else" portion.

4
  • 1
    What is the issue you are facing ?
    – Midhun MP
    Jun 22, 2013 at 11:05
  • 4
    if (region_0 <= 0.0);? What's that ; doing there? Why the empty block a couple lines below? Please format your code.
    – Mat
    Jun 22, 2013 at 11:05
  • Your parenthesis are wrong towards the end.
    – Jean-Luc
    Jun 22, 2013 at 11:05
  • There's s.th. totally messed up in the structure Jun 22, 2013 at 11:15

1 Answer 1

3

Change

else
{   
if (region_0 <= 0.0);
}
sales_tax_region= region_1 * .65;
{
}

to

else
if (region_0 <= 0.0) {
  sales_tax_region= region_1 * .65;
}
1
  • It would be nice if you could indent the code correctly to make it readable. Jun 22, 2013 at 11:37

Not the answer you're looking for? Browse other questions tagged or ask your own question.