Skip to content

Instantly share code, notes, and snippets.

@joeyv
Created October 24, 2013 17:20
Show Gist options
  • Select an option

  • Save joeyv/7141387 to your computer and use it in GitHub Desktop.

Select an option

Save joeyv/7141387 to your computer and use it in GitHub Desktop.
calculate your payroll
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