logotransparent.png

Legion of Learners

www.lol-101.com

  • Home

  • Classrooms

  • Courses

  • About Us

    • Executive Team
    • Board Members
  • Resources

  • More

    Use tab to navigate through the menu items.
    To see this working, head to your live site.
    • Categories
    • All Posts
    • My Posts
    sfolax6776
    Oct 08, 2018
      ·  Edited: Nov 03, 2020

    4.4 - Why do we need nested if... else...?

    in Introduction to Java

    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:

    E5.2 - E5.25

    7 comments
    0
    Davey Yu
    Oct 10, 2018  ·  Edited: Oct 10, 2018

    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

    0
    Davey Yu
    Oct 10, 2018

    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.

    0
    danny481
    Oct 14, 2018

    In the first one, it both has if. In the second one, the second piece of code has else if

    0
    trjoshi3011
    Oct 14, 2018  ·  Edited: Oct 14, 2018

    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.


    0
    danny481
    Oct 14, 2018

    a is m, b is n, and c and d is error

    0
    danny481
    Oct 20, 2018  ·  Edited: Oct 21, 2018

    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

    0
    Davey Yu
    Oct 21, 2018

    https://repl.it/@DaveyYu/Homework-for-102118


    0
    7 comments

    Questions? Email us at legionoflearners@gmail.com or join our WeChat group!

    • lol-101dotcom

    ©2020 Legion of Learners