Advertisement
Arush22

Homework 1-19 and 31-41 in unit 5 Corrected v.3

Jan 14th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. 1.99 KB
  2. 1. True, True, False, false, True, True, True
  3. 2. False, True, False, True, False, True, False, False
  4. 3. Yes
  5. 4. Yes
  6. 5. Yes
  7. 6. Yes
  8. 7. No, Yes, Yes, No
  9. 8. if, else if, else
  10. 9. Using the equals method
  11. 10. 1
  12. 11. 0
  13. 12. Inside true block
  14. End of sequence
  15. 13. 27 is divisible by 3
  16. End of Sequence
  17. 14. String is not hello
  18. End of sequence
  19. 15. C
  20. Done
  21. 16. Hello 3
  22. Hello 4
  23. Done
  24. 17. Season is Summer
  25. 18. letter 2
  26. 19. Number 3
  27. 31. b1 is a Boolean and can't be set to an integer value. && is not a number operator.
  28. 32. AND should be written as &&.
  29. 33. Curly brackets should replace the semicolon after the if statement and should encapsulate the System.out.print code that will be performed.
  30. 34. Parenthesis should surround b1 after the if statement and curly brackets should surround the operation to be performed.
  31. 35. Parenthesis, not curly brackets, should surround b2 after the if statement.
  32. 36. else should come after else if otherwise else if won't be performed.
  33. 37. No Error
  34. 38. Because the if tests a value and the else if compares a different two values it is possible for both to be true but the else if will never execute even if its true, if the if statement is true.
  35. 39. It can't read the if statement because there are not brackets surrounding the code to be performed. Put brackets around the operation to be formed after the if statement.
  36. 40. The value of a is being set to 31 rather than being compared to it. Replace "=" with "==";
  37. 41. The bracket that encloses the code to be performed after the if statement extends past the else statement which means that the compiler doesn't know where to stop executing the code for the if statement so it can't read it. Place a closing curly bracket before the else statement and an opening curly bracket immediately after the else statement.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement