Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This was a simple project I had to make for class.
- package com.school;
- public class WageCalculator {
- //fields
- private double baseRate;
- private double overTimeMultiplier;
- private int hours;
- //constructors
- public WageCalculator(double a,int b,double otMultiplier){
- if(a >= 7.25)
- baseRate = a;
- if(b > 0)
- hours = b;
- if(otMultiplier == 0)
- overTimeMultiplier = 1.5;
- if(otMultiplier != 0)
- overTimeMultiplier = otMultiplier;
- }
- public double baseWage(){
- double a = 0;
- if(hours <= 40 && hours > 0)
- a = baseRate * hours;
- if(hours > 40)
- a = baseRate * 40;
- return a;
- }
- public double overtimeWage(){
- double overTimeHours;
- if(hours > 40)
- overTimeHours = hours - 40;
- else
- overTimeHours = 0;
- double overtimeRate = baseRate * overTimeMultiplier;
- double overtimePay = overtimeRate * overTimeHours;
- return overtimePay;
- }
- public double totalWage(){
- double wage = baseWage() + overtimeWage();
- return wage;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement