Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public class Student {
  2. public static void main(String[] args) {
  3. int cash;
  4.  
  5. cash = startingSalary(3.87, 178, 16); // 0
  6. System.out.println(cash);
  7.  
  8. cash = startingSalary(1.99, 185, 55); // 0
  9. System.out.println(cash);
  10.  
  11. cash = startingSalary(2.7, 380, 50); // 65000
  12. System.out.println(cash);
  13.  
  14. cash = startingSalary(3.7, 200, 29); // 77700
  15. System.out.println(cash);
  16.  
  17. cash = startingSalary(3.7, 200, 30); // 115700
  18. System.out.println(cash);
  19.  
  20. cash = startingSalary(3.8, 185, 0); // 115700
  21. System.out.println(cash);
  22. }
  23.  
  24. // Convince yourself the parameter types make sense.
  25. public static int startingSalary(double gpa, int total, int honors) {
  26. if (total < 180) {
  27. // I get no money if I haven't graduated.
  28. return 0;
  29. }
  30. else if (gpa < 2.0) {
  31. // I also get no money if my gpa is less than 2.0;
  32. return 0;
  33. }
  34.  
  35. // Honors credit multiplier. Make sure to use double division.
  36. if ((double) honors / total >= 0.15)
  37. gpa *= 1.15;
  38.  
  39. if (gpa < 2.8) {
  40. return 65000;
  41. }
  42. else if (gpa < 3.8) {
  43. return 77700;
  44. }
  45.  
  46. // If I've reached this point, my gpa is >= 2.8 and >= 3.8. $$$.
  47. return 115700;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement