[英]Getting an illegal start of type error
I am getting an "illegal start of type" error with this block: 我收到此块的“非法开始类型”错误:
if (maritalStatus.equals("Single") || maritalStatus.equals("single")){
taxableIncome = grossIncome - deductions - (dependents * allowance);
} else if (maritalStatus.equals("Married") || maritalStatus.equals("married")){
taxableIncome = grossIncome - deductions - ((dependents + 2) * allowance);
}
Also, how do I use the below statement when it comes to single/Single and married/Married? 另外,对于单身/单身和已婚/已婚,我该如何使用以下声明?
Boolean equalsIgnoreCase (String thisString)
I have no idea why you are getting an error with your code, but you would use equalsIgnoreCase like this: 我不知道为什么您的代码出错,但是您将使用equalsIgnoreCase这样:
if (maritalStatus.equalsIgnoreCase("Single")) {
taxableIncome = grossIncome - deductions - dependents * allowance;
} else if (maritalStatus.equalsIgnoreCase("Married")) {
taxableIncome = grossIncome - deductions - (dependents + 2) * allowance;
}
I also took out your extraneous parentheses. 我还拿出了你多余的括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.