我寫一個程序基本上詢問用戶是否Java程序 - 加油站泵
- 他們是會員(是/否),10%的折扣,如果是
- 氣體的精品級(3種價格3年級) 然後返回與小計和稅收+總
這裏的發票是我想出了
我得到了一個錯誤說「無法找到符號」爲我的變量(加侖/ G rade/memberYN)
我該如何解決?
這裏是我的錯誤信息 http://puu.sh/8A60K/f9201eb57e.jpg
import java.util.Scanner;
public class Kang_Invoice2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Are you a member?");
memberYN = input.nextLine();
System.out.println("Quality of Gas:");
grade = input.nextInt();
System.out.println("Gallons sold:");
gallon = input.nextDouble();
double subtotal;
double countyTaxRate = 0.07;
double cityTaxRate = 0.0375;
double price87 = 3.87;
double price89 = 3.98;
double price91 = 4.01;
double total = subtotal * 1.1075;
double countyTax = subtotal * countyTaxRate;
double cityTax = subtotal * cityTaxRate;
double gallon;
int grade ;
if(memberYN.equalsIgnoreCase("yes"))
{
if (grade == 87)
{subtotal = price87 * gallon * 0.9;};
if (grade == 89);
{subtotal = price89 * gallon * 0.9;};
if (grade == 91);
{subtotal = price91 * gallon * 0.9;};
}
elseif(memberYN.equalsIgnoreCase("no"));
{
if (grade == 87)
{
subtotal = price87 * gallon;
};
if (grade == 89);
{
subtotal = price89 * gallon ;
};
if (grade == 91);
{
subtotal = price91 * gallon;
};
}
System.out.println("INVOICE FOR GASOLINE");
System.out.println("Member status" + (memberYN.equalsIgnoreCase("yes") ? "yes" : "no")
);
System.out.println("Gasoline Sold/Price:" + gallon + "@");
System.out.println("\n");
System.out.println("Subtotal : $" + subtotal);
System.out.println("County Tax : $" + countyTax);
System.out.println("City Tax : $" + cityTax);
System.out.println("-------------");
System.out.println("Total : $ " + total);
}
}
截圖
輸入? –
對「無法找到符號」的含義進行搜索會更好。問題的標題與實際的具體問題無關。 –