Advertisement
ThePunsGuy

My Comp Sci Prof. Said This Couldn't Be Done Without If

Sep 11th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.71 KB | None | 0 0
  1.     private static void overTimeWithoutIf(){
  2.         double hours;
  3.         double wage;
  4.         double totalNoOT;
  5.         double totalWithOT;
  6.         double realValue;
  7.  
  8.         Scanner in = new Scanner(System.in);
  9.  
  10.         //Input information from user
  11.         System.out.println("What were your hours?");
  12.         hours = in.nextDouble();
  13.         System.out.println("What is your hourly wage?");
  14.         wage = in.nextDouble();
  15.  
  16.         //Calculate total without and with overtime
  17.         totalNoOT = hours*wage;
  18.         totalWithOT = 40*wage + ((hours-40) *wage*1.5);
  19.  
  20.         realValue = Math.max(totalNoOT,totalWithOT);
  21.  
  22.         System.out.println("Your total payment for this week is: $" + realValue);
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement