-
-
Save ArtSabintsev/d2f7be97e69f8f17f133 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 | |
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())); | |
} | |
} |
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 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