Reputation: 19
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)
Upvotes: 0
Views: 133
Reputation: 35
I have no idea why you are getting an error with your code, but you would use equalsIgnoreCase like this:
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.
Upvotes: 1