A. Introduction
Take a look at the table below to decide how income tax is calculated:
To calculate a person's income tax, we need to decide if a person is married or not. Then based on his or her taxable income, we apply a different tax rate. The decision-making process is shown below.
The taxable income condition is checked after the marital status is checked. As mentioned in 2.7, this is a situation of nested if... else.
B. Sample code: IncomeTax.java
C. Try:
https://repl.it/@DaveyYu/Homework-for-102118
R5.2: The second one has else if, not if.
R5.4: 1. m 2.n 3.error 4. error
R5.3: a. there shouldn't be a "then" b. the brackets aren't closed so yeah c. there is no System.out.println at y++; d. same as c and no brackets on sum = sum + x e. no place for F
4.https://repl.it/@Brainseater905/UntidyFrivolousAddon
a is m, b is n, and c and d is error
R5.2) The first code has both if statements but the second code has one if and an else if statement
R5.4) a. m b. n c. error d. error
R5.3) a. It says then which it shouldn't b. It didn't close the brackets c. There has to be double = signs d. In the if statement the String is not the same as the x String e. There is no default statement in the code.
In the first one, it both has if. In the second one, the second piece of code has else if
R5.3 a. uhhh why is there a "then". b. missing a ) c. missing a = at "if (x = 1) d. what the heck is in.hasNextInt? e. must be else if, not if.
R5.2 the second one includes an else if, but the first one only includes and if.
R5.4 a. m b. n c. error d. error