Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Student {
- public static void main(String[] args) {
- int cash;
- cash = startingSalary(3.87, 178, 16); // 0
- System.out.println(cash);
- cash = startingSalary(1.99, 185, 55); // 0
- System.out.println(cash);
- cash = startingSalary(2.7, 380, 50); // 65000
- System.out.println(cash);
- cash = startingSalary(3.7, 200, 29); // 77700
- System.out.println(cash);
- cash = startingSalary(3.7, 200, 30); // 115700
- System.out.println(cash);
- cash = startingSalary(3.8, 185, 0); // 115700
- System.out.println(cash);
- }
- // Convince yourself the parameter types make sense.
- public static int startingSalary(double gpa, int total, int honors) {
- if (total < 180) {
- // I get no money if I haven't graduated.
- return 0;
- }
- else if (gpa < 2.0) {
- // I also get no money if my gpa is less than 2.0;
- return 0;
- }
- // Honors credit multiplier. Make sure to use double division.
- if ((double) honors / total >= 0.15)
- gpa *= 1.15;
- if (gpa < 2.8) {
- return 65000;
- }
- else if (gpa < 3.8) {
- return 77700;
- }
- // If I've reached this point, my gpa is >= 2.8 and >= 3.8. $$$.
- return 115700;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement