kp03
kp03

Reputation: 19

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)

Upvotes: 0

Views: 133

Answers (1)

Ezra-Shimon
Ezra-Shimon

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

Related Questions