Created
February 28, 2015 23:54
-
-
Save JoeValenti/2549d84c2425c2b56283 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DecimalFormat; | |
import java.util.Scanner; | |
public class PayAmmount { | |
public static void main(String[] args) { | |
double payRate, hoursWorked, totalPay; | |
Scanner keyScan = new Scanner(System.in); | |
Payroll myPayRoll; | |
// User input | |
System.out.print("What is your rate of pay: "); | |
payRate = keyScan.nextDouble(); | |
System.out.print("How many hours did you work this week: "); | |
hoursWorked = keyScan.nextDouble(); | |
myPayRoll = new Payroll(payRate,hoursWorked); | |
DecimalFormat moneyFormat = new DecimalFormat("$###,##0.00"); | |
System.out.print("My pay check this week will be: "); | |
System.out.println(moneyFormat.format(myPayRoll.getPayRate())); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Payroll { | |
//Declare Variables | |
private double payRate; | |
private double hoursWorked; | |
private double totalPay; | |
public Payroll(double hourlyWage, double hours){ | |
payRate = hourlyWage; | |
hoursWorked = hours; | |
if (hours > 40){ | |
hours = (hours *1.5); | |
} | |
} | |
public void calcPay(){ | |
totalPay = payRate * hoursWorked; | |
} | |
public double getHours(){ | |
return hoursWorked; | |
} | |
public double getPayRate(){ | |
return (payRate*hoursWorked); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment