Skip to content

Instantly share code, notes, and snippets.

@ArtSabintsev
Forked from JoeValenti/PayAmmount.java
Last active August 29, 2015 14:16
Show Gist options
  • Save ArtSabintsev/d2f7be97e69f8f17f133 to your computer and use it in GitHub Desktop.
Save ArtSabintsev/d2f7be97e69f8f17f133 to your computer and use it in GitHub Desktop.
import java.text.DecimalFormat;
import java.util.Scanner;
public class PayAmmount {
public static void main(String[] args) {
double payRate
double hours;
Scanner keyScanner = new Scanner(System.in);
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();
Payroll 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()));
}
}
public class Payroll {
// Declare Variables
private double payRate;
private double hours;
// Initializer
public Payroll(double inputPayRate, double inputHours){
payRate = inputPayRate;
if (inputHours > 40){
hours = 40 + ((inputHours-40) * 1.5);
} else {
hours = inputHours;
}
}
// Get's rate as payRate * hoursWorked
public double getTotalPay() {
return (payRate*hours);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment