if else语句不会执行

时间:2013-06-22 11:02:59

标签: c++ if-statement

我在编写“if”“else”语句时遇到了麻烦,但是当我运行该程序时它不会执行。

#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;
}

这是我正在使用的要求使用“if-else”结构来确定要使用的V8价格。使用另一个“if-else”结构来确定要根据区域代码选择的销售税值。

我完全迷失在“if”“else”部分。

1 个答案:

答案 0 :(得分:3)

更改

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

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