1 / 54

int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one");

int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four");. x = 3. int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one");

gibson
Download Presentation

int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one");

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four");

  2. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four");

  3. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1

  4. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 true x > 2

  5. x = 3 int x = 3; if (x > 1) if (x > 2){ if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2

  6. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3

  7. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one”

  8. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” }

  9. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” }

  10. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” }

  11. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); }else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” }

  12. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); }elseSystem.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” }

  13. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); }else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” }

  14. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” }

  15. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” }

  16. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” “four” }

  17. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” “four” }

  18. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” “four” } The end.

  19. x = 3 int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); true x > 1 { true x > 2 true x > 3 “one” “three” “four” } The end. The end. Nothing gets printed.

  20. int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); Old problem

  21. int x = 3; if (x > 1) { if (x > 2) if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); New problem

  22. Old problem int x = 3; if (x > 1) if (x > 2) { if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four");

  23. New problem int x = 3; if (x > 1) { if (x > 2) if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four");

  24. New problem int x = 3; if (x > 1) { if (x > 2) if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); else w/out if Does not compile!

  25. New problem int x = 3; if (x > 1) { if (x > 2) if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); else w/out if Does not compile! The only solution, then, is to carefully draw the flowchart!

  26. New problem int x = 3; if (x > 1) { if (x > 2) if (x > 3) System.out.println("one"); } else System.out.println("three"); else System.out.println("four"); else w/out if Does not compile! The only solution, then, is to carefully draw the flowchart! There really isn’t any reliable, uniform shortcut alternative to that.

  27. Let’s take a look at the lab assignment.

  28. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  29. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  30. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  31. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  32. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  33. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  34. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  35. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  36. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  37. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  38. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  39. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  40. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  41. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  42. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  43. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  44. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  45. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  46. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  47. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  48. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  49. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

  50. initialize the amount the user needs to pay while (the amount due is more than zero) { prompt the user for input (a line) get the line and prepare to take it apart while (there are still tokens available) { get next token (call it token) interpret it, and update amount } // if you get here you’re done with the line // but the amount due can still be positive } // if you get here the amount due is zero or less

More Related