0
當這些被我得到,當我嘗試運行我的程序below..have不知道如何解決them..just錯誤開始學習java:獲取操作故障運行的徵稅方案
C:\Users\Bryce\Desktop\1504\taxable.java:14: error: bad operand types for binary operator '<'
(salary >= 15000<20000) {
^
first type: boolean
second type: int
C:\Users\Bryce\Desktop\1504\taxable.java:17: error: bad operand types for binary operator '<='
(salary>=15000<=35000); {
^
first type: boolean
second type: int
2 errors
Process completed.
------------------------------------------------------------------------------------------
代碼:
import java.util.*;
public class taxable {
public static void main (String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter your salary:");
double salary=in.nextDouble();
double taxDue;
if (salary < 15000) {
System.out.println("No tax applicable");
}
if (salary >= 15000<20000) {
taxDue=15000*10/100;
}
if (salary>=15000<=35000);
{
taxDue=15000*10/100+20000*20/100;
}
if (salary > 35000);
{
taxDue=(15000*10/100)+(20000*20/100)+(salary-35000)*35/100;
}
System.out.printf("The amount of tax due is: " + taxDue + " ");
double avTaxRate;
avTaxRate=taxDue/salary*100;
System.out.printf("The average tax rate: " + taxDue + "%%");
}
}
所以編譯器說和informatively顯示它:'工資> = 15000 <20000'「不好操作類型的二元運算符‘<’」 –