Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. //This was a simple project I had to make for class.
  2. package com.school;
  3. public class WageCalculator {
  4.  
  5. //fields
  6. private double baseRate;
  7. private double overTimeMultiplier;
  8. private int hours;
  9.  
  10.  
  11. //constructors
  12. public WageCalculator(double a,int b,double otMultiplier){
  13.  
  14.  
  15. if(a >= 7.25)
  16. baseRate = a;
  17.  
  18. if(b > 0)
  19. hours = b;
  20.  
  21. if(otMultiplier == 0)
  22. overTimeMultiplier = 1.5;
  23. if(otMultiplier != 0)
  24. overTimeMultiplier = otMultiplier;
  25.  
  26.  
  27. }
  28.  
  29. public double baseWage(){
  30. double a = 0;
  31. if(hours <= 40 && hours > 0)
  32. a = baseRate * hours;
  33. if(hours > 40)
  34. a = baseRate * 40;
  35.  
  36. return a;
  37. }
  38. public double overtimeWage(){
  39. double overTimeHours;
  40. if(hours > 40)
  41. overTimeHours = hours - 40;
  42. else
  43. overTimeHours = 0;
  44.  
  45. double overtimeRate = baseRate * overTimeMultiplier;
  46. double overtimePay = overtimeRate * overTimeHours;
  47. return overtimePay;
  48.  
  49. }
  50. public double totalWage(){
  51. double wage = baseWage() + overtimeWage();
  52. return wage;
  53. }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement