public class Salary {

  // regHours : takes a number, returns the number of hours at base pay

  // otHours : takes a number, returns the number of hours of overtime
// A:
// 45 44 36
/* public static int regHours(int hours) {
  return Math.max(hours, 40);
}
public static int otHours(int hours) {
  return Math.max(40, hours) - hours;
} */
// B:
/* public static int regHours(int hours) {
  return Math.max(hours, 40);
}
public static int otHours(int hours) {
  return Math.min(0, hours - 40);
} */

// C:
// D:
/*
public static int regHours(int hours) {
  return Math.min(hours, 40);
}
public static int otHours(int hours) {
  return hours - regHours(hours);
}
*/


  public static int regHours(int hours) {
    return Math.min(hours, 40);
  }
  public static int otHours(int hours) {
    return Math.max(0, hours - 40);
  }

  // weekly : take two numbers (ints), hours worked and rate,
  // and evaluate to the total pay for the week, including overtime
  public static int weekly(int hours, int rate) {
    return regHours(hours) * rate + otHours(hours) * rate * 2;
  }

  public static void main(String[] args) {

    // Hours worked: 45, 42, 36

    // Hourly pay:   16, 11, 19

    // Total pay is the number of hours worked up to 40 times the base pay
    // plus the number of hours worked over 40 times twice the base pay
    System.out.println(40 * 16 + 5 * 16 * 2);
    System.out.println(40 * 11 + 2 * 11 * 2);
    System.out.println(36 * 19 + 0 * 19 * 2);

    System.out.println(weekly(45, 16));
    System.out.println(weekly(42, 11));
    System.out.println(weekly(36, 19));
    

  }
}





























// Helpers:
// A:
/* public static int regHours(int hours) {
    return Math.max(hours, 40);
  }
  public static int otHours(int hours) {
    return Math.max(40, hours) - hours;
  }
*/
// B:
/* public static int regHours(int hours) {
    return Math.max(hours, 40);
  }
  public static int otHours(int hours) {
    return Math.min(0, hours - 40);
  }
*/
// C:
/* public static int regHours(int hours) {
    return Math.min(hours, 40);
  }
  public static int otHours(int hours) {
    return Math.max(0, hours - 40);
  }
*/
// D:
/* public static int regHours(int hours) {
    return Math.min(hours, 40);
  }
  public static int otHours(int hours) {
    return hours - regHours(hours);
  }
*/














  /*

  TRACE

A:
    regHours(45) * 16 + otHours(45) * 16 * 2;
->  Math.min(45, 40) * 16 + otHours(45) * 16 * 2
->  40 * 16 + otHours(45) * 16 * 2
->  640 + otHours(45) * 16 * 2
->  640 + (45 - regHours(45)) * 16 * 2
->  640 + (45 - (Math.min(45, 40))) * 16 * 2
->  640 + (45 - 40) * 16 * 2
->  640 + 5 * 16 * 2


B:
    regHours(45) * 16 + otHours(45) * 16 * 2;
->  regHours(45) * 16 + (45 - regHours(45)) * 16 * 2
->  regHours(45) * 16 + (45 - Math.min(45, 40)) * 16 * 2
->  regHours(45) * 16 + (45 - 40) * 16 * 2
->  regHours(45) * 16 + 5 * 16 * 2
->  Math.min(45, 40) * 16 + 5 * 16 * 2
->  40 * 16 + 5 * 16 * 2


C:
    regHours(45) * 16 + otHours(45) * 16 * 2
->  Math.min(45, 40) * 16 + otHours(45) * 16 * 2
->  40 * 16 + otHours(45) * 16 * 2
->  640 + otHours(45) * 16 * 2
->  640 + Math.min(45, 40) * 16 * 2
->  640 + 40 * 16 * 2


  */
