import java.io.*; import java.lang.*; public class payroll { public static void main(String args[]) throws FileNotFoundException { Scanner scr = new Scanner(System.in); String date1 = ""; String name = ""; float wage = 0; int dep = 0; int r_red = 0; float[] hours = new float[6]; int empid = 0; String file = ""; System.out.print("Enther your employee #: "); empid = scr.nextInt(); int test = (empid >= 0 && empid < 10) ? 1 : 0; test = (empid >= 10 && empid < 100) ? 2 : test; test = empid >= 100 ? 3 : test; switch(test) { case 1: file = "00" + empid + "-hours.txt"; break; case 2: file = "0" + empid + "-hours.txt"; break; case 3: file = empid + "-hours.txt"; break; } Scanner s2 = new Scanner(new File(file)); date1 = s2.next().toString(); name = s2.next().toString() + " " + s2.next().toString(); String stest = s2.next().toString(); test = ((int)stest.charAt(0) >= 65 && (int)stest.charAt(0) <= 122) ? 1 : 0; switch(test) { case 1: name = name + " " + stest; wage = s2.nextFloat(); break; case 0: wage = Float.valueOf(stest).floatValue(); break; } dep = s2.nextInt(); r_red = s2.nextInt(); int numhours = 0; for(int i = 0; i < 5; i++) { hours[i] = s2.nextFloat(); numhours += hours[i]; } float pay = 0; int overhours = 0; test = numhours > 40 ? 40 : numhours; overhours = numhours > 40 ? numhours - 40 : 0; pay = (float)((overhours * 1.5 * wage) + (test * wage)); pay -= 100 + (50*dep); pay -= r_red; pay -= pay * ( 0.18 - (0.02*dep)); pay = pay < 0 ? 0 : pay; System.out.println(date1); System.out.println("Pay to the order of " + name + ": " + "$"+pay); System.out.println("Memo: employee #" +empid + " for the period 01/03/05 through 01/07/05"); } }