Hey all, I have an assignment due tonight and I think I got it about wrapped up, just a few errors with my variables. Let me know if you guys need additional information to help me figure this out!
import java.util.Scanner; import java.util.Calendar; //Program uses class Scanner and Calendar public class NewCode { private static Scanner input = new Scanner (System.in); private static int firstNmLength; private static Calendar dateTime = Calendar.getInstance(); private static int trigger = 1; public static void main(String [] args) { generateReport(); System.exit(0); } public static void generateReport() { char cont; cont = 'Y'; while(Character.toUpperCase(cont) == 'Y') { setEmployeeName(first); employeeName.substring(0, firstNmLength); setHoursWorked(hoursWorked); while(hoursWorked > 40 || hoursWorked < 5) { testHoursWorked(); } setPayRate(payRate); while(payRate < 7.25 || payRate > 15) { testPayRate(); } double grossPay= hoursWorked*payRate; grossPayTotal= grossPay-grossPayTotal; set401K(); while(percent401K > 10) { test401K(); } if(trigger == 1) { formatDollarSign(); } else { formatNoDollarSign(); } input.nextLine(); System.out.printf("Enter \'Y\' to add another employee or \'N\' to exit: "); cont= input.nextLine().charAt(0); } } //begin sub-methods public static String setEmployeeName() { System.out.printf("Enter the employee's first and last name: "); String first = input.next(); String last = input.next(); first.length(); return first; } public static int setHoursWorked(String first) { System.out.printf("Enter the number of hours worked for %s: ",first); hoursWorked = input.nextInt(); return hoursWorked; } public static int testHoursWorked(int hoursWorked) { if(hoursWorked > 40) { System.out.printf("Hours worked cannot exceed 40. Please re-enter: "); hoursWorked = input.nextInt(); } else if(hoursWorked < 5) { System.out.printf("Hours worked cannot be less than 5. Please re-enter: "); hoursWorked = input.nextInt(); } return hoursWorked; } public static double setPayRate() { System.out.printf("Enter the employee's hourly pay rate: "); double payRate = input.nextDouble(); return payRate; } public static double testPayRate(double payRate) { if(payRate < 7.25) { System.out.printf("Hourly pay cannot be less than $7.25. Please re-enter: "); payRate = input.nextDouble(); } else if(payRate > 15) { System.out.printf("Hourly pay cannot exceed $15.00. Please re-enter: "); payRate = input.nextDouble(); } return payRate; } public static double set401K() { System.out.printf("Enter the employee's 401K contribution as a percentage of salary: "); double percent401K=input.nextDouble(); return percent401K; } public static double test401K() { System.out.printf("Contribution cannot exceed 10%%. Please re-enter: "); double percent401K=input.nextDouble(); double retire401K= (percent401K/100)*grossPay; total401K= total401K+retire401K; return percent401K; } public static String formatDollarSign(String first, String last, double grossPay, double percent401K) { payrollExpense += String.format("\n %-30s %8s $%,21.2f %8s $%,19.2f",first +" "+ last," ",grossPay," ",retire401K); trigger = 0; return payrollExpense; } public static String formatNoDollarSign(String first, String last, double grossPay, double percent401K) { payrollExpense += String.format("\n %-30s %9s %,21.2f %9s %,19.2f",first +" "+ last," ",grossPay," ",retire401K); return payrollExpense; } }