liangm20

Chapter 2: 4-40

Sep 13th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. 4. 12.5
  2. 5. 6
  3. 6. 13.0
  4. 7. 2.6
  5. 8. 2
  6. 9. 3
  7. 10. 4
  8. 11. 1
  9. 12. 7
  10. 13. 5
  11. 14. 2.4
  12. 15. 2
  13. 16. 2.4
  14. 17. 2.0
  15. 18. 6
  16. 19. 4
  17. 20. 4
  18. 21. 7
  19. 22. 0
  20. 23. float a = 34.2;
  21. 24. int a = 10;
  22. 25. boolean a = false;
  23. 26. char a = B;
  24. 27. int total = a + b + c;
  25. System.out.println( total );
  26. 28. float average = (a + b) / 2;
  27. System.out.println( average );
  28. 29. int remainder = a % b;
  29. System.out.println( remainder );
  30. 30. a++;
  31. 31. a*=3;
  32. 32. b = (a + 3) - 7;
  33. b = a*4;
  34. a = b*b;
  35. a = b*3*5;
  36. b = a/2;
  37. b = a%3;
  38. 33. 3.3 is not an integer
  39. 34. the 2 variables aren't compatible because double is greater than float
  40. 35. 7.5 is not an integer
  41. 36. Exception in thread "main" java.lang.ArithmeticException: / by zero
  42. 37. a--, not a -
  43. 38. no error, because 67 is a capital C, which is one character
  44. 39. yes, boolean can only be true or false
  45. 40. the problem is that 26.4 is not an integer; replace int with double
Add Comment
Please, Sign In to add comment