/* Gross Pay Calculator CIS 160 David G. Klick 2004-08-27 Basic gross pay calculator that includes overtime. */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; public class PayCalc { public static void main(String[] args) throws IOException { // set up object to read from keyboard BufferedReader kbd = new BufferedReader( new InputStreamReader(System.in)); // declare and initialize variables double hours = 0.0, rate = 0.0, gpay = 0.0; String s; // get hours System.out.print("Enter hours worked: "); s = kbd.readLine(); hours = Double.parseDouble(s); // get rate System.out.print("Enter hourly rate: "); s = kbd.readLine(); rate = Double.parseDouble(s); // calculate gross pay if (hours <= 40.0) { gpay = hours * rate; } else { gpay = (40 * rate) + ((hours - 40) * (rate * 1.5)); } // display gross pay System.out.println("\nThe gross pay is: $" + gpay); } } /* Sample of one run of program: Enter hours worked: 50 Enter hourly rate: 30 The gross pay is: $1650.0 */