Created
October 24, 2013 17:20
-
-
Save joeyv/7141387 to your computer and use it in GitHub Desktop.
calculate your payroll
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.util.Scanner; | |
| import java.text.*; | |
| public class Payroll{ | |
| public static void main(String []args){ | |
| double hourPay, hourWorked; | |
| double overtime, total; | |
| Scanner scan = new Scanner(System.in); | |
| hourPay = scan.nextInt(); | |
| hourWorked = scan.nextInt(); | |
| //seeing if you worked overtime | |
| if (hourWorked > 40){ | |
| overtime = (hourWorked - 40) * (hourPay * 1.5); | |
| total = (hourPay * 40) + overtime; | |
| } else { | |
| total = hourPay * hourWorked; | |
| } | |
| //formating currency | |
| NumberFormat nf = NumberFormat.getCurrencyInstance(); | |
| System.out.println("You made " + nf.format(total) + " this week!"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment