Question: Only take this question if you are willing to answer, I have posted this question now a few times and have yet for anyone to
Only take this question if you are willing to answer, I have posted this question now a few times and have yet for anyone to answer it I really need some help so please can someone answer this question, I dont wanna pay for something that is not helping me. Ive tried to make it as clear and simple to follow as I can. In my testdriver class i need to modify it so I can implement a file njgov.txt which will be listed below along with my code. The main goal is basically to print out checks for these people. The list starts with the name of someone, followed by the hours worked, then pay rate amount per hour, lastly did they work a holiday (yes/no) doesnt matter how many holiday hours they worked. Let the program Automatically create an array of the correct size to handle the number of paychecks. You will need to know how many entries are in the file before creating the array. Don't manually count the number of entries in the file. Let your program initially read the number of entries to obtain a count. NOTE: be sure to close the file after reading it to count entries. Then you will have to reopen it to actually start loading the newly created array of checks with data. TASKS: Once you have the array loaded with your data. Print out all of the checks. Since there is so much data now, when printing allow the screen to pause every 5 checks. After every 5 checks are printed display the following message to the user: Press ENTER to continue Ideally this would best be done be a static method such as: Static void printPayroll(Paycheck [] company, There are 7 statical things listed at the bottom of the test driver class all we need to add is to display the name and wages of people who worked a holiday. EXTRA CREDIT: Sort the array from the highest earner to the lowest earner and then printout the checks (pausing every 5 checks as described above).
--------------------------------------------------------------------------------------------------
Test driver class
import java.util.Scanner; import paycheck.Paycheck;
public class Testdriver { static Scanner console = new Scanner(System.in);
public static void main(String[] args) { double sumOfPay = 0; double hours = 0; Paycheck[] company = new Paycheck[3]; for (int index = 0; index < 3; index++) { company[index] = new Paycheck(); company[index].askName(); company[index].askHours(); company[index].askRate(); company[index].isHoliday(); company[index].calculatePay(); Paycheck.clearbuffer(); } double maxHours = company[0].getHours(); String maxName =company[0].getName();
double minHours = company[0].getHours(); String minName =company[0].getName();
double holidayWage =0; String holidayName ="";
double maxWage=company[0].getWages(); String maxWageName =company[0].getName();
System.out.println("Company Payroll: "); for (int index = 0; index < 3; index++) { company[index].printCheck(); sumOfPay = sumOfPay + company[index].getWages(); hours = hours + company[index].getHours(); if(maxHours < company[index].getHours()){ maxHours=company[index].getHours(); maxName = company[index].getName(); }
if(minHours > company[index].getHours()){ minHours=company[index].getHours(); minName = company[index].getName(); }
if(maxWage < company[index].getWages()){ maxWage=company[index].getWages(); maxWageName = company[index].getName(); } if("Yes".equalsIgnoreCase(company[index].getHoliday())){ holidayWage = company[index].getWages(); holidayName = company[index].getName(); } System.out.println(); } System.out.println("1.Gross Pay Of Company = " + sumOfPay); double averageHours = hours / company.length; System.out.println("2.Average hours worked for company = " + averageHours); double averagePay = sumOfPay / company.length; System.out.println("3.Average Gross Pay for company = " + averagePay); System.out.println("4.Max Hour Employee Name = " + maxName +" hours = "+maxHours); System.out.println("5.Min Hour Employee Name = " + minName +" hours = "+minHours); System.out.println("6.Taken Holiday Employee Name = " + holidayName +" gross Pay = "+holidayWage); System.out.println("7.Max Wage Employee Name = " + maxWageName +" gross Pay = "+maxWage);
} }
----------------------------------------------------------------------
Paycheck Class
import java.util.Scanner;
public class Paycheck {
static Scanner console = new Scanner(System.in);
public static void clearBuffer() { throw new UnsupportedOperationException("Not supported yet."); } private double wages; private double rate; private double hours; private String holiday; private String name;
Paycheck(){ wages=0; rate=0; hours=0; holiday=""; name = ""; }
public double getWages() { return wages; }
public void setWages(double wages) { this.wages = wages; } public double getRate() { return rate; }
public void setRate(double rate) { this.rate = rate; }
public double getHours() { return hours; }
public void setHours(double hours) { this.hours = hours; }
public String getHoliday() { return holiday; }
public void setHoliday(String holiday) { this.holiday = holiday; }
public String getName() { return name; } public void setName(String name) { this.name = name; }
public void askHours(){ do{ System.out.println("Line 2: Enter the working "+"hours"); hours= console.nextDouble(); if(hours>168 || hours<1){ System.out.println("Invalid Input !! Try Again"); } }while(hours>168 || hours<1);
}
public void calculatePay(){ if(holiday.equalsIgnoreCase("Yes")){ wages=rate*2*hours; }else{ if(hours>40.0) { wages=40.0*rate+1.5*rate*(hours-40.0); }else{ wages = hours*rate; } } }
public void isHoliday(){ boolean invalidYN; do{ System.out.println("Were the hours worked during a holiday(yes/no)?"); holiday=console.next(); invalidYN = !holiday.equalsIgnoreCase("No") && !holiday.equalsIgnoreCase("Yes"); if(invalidYN) System.out.println("Please Type 'Yes' or 'No'!"); }while(invalidYN); }
public void askRate(){ System.out.println(); System.out.print("line 5: Enter The pay "+"rate :"); rate=console.nextDouble(); System.out.println(); }
public void printCheck(){ System.out.println(" Employee Name: " +name); System.out.printf("Line 12: The wages are $%.2f %n",wages); System.out.println(); }
public void askName(){ System.out.print("Enter Employee name :"); name = console.nextLine(); }
public static void clearbuffer(){ console.nextLine(); } }
---------------------------------------------------------------------------------------------------------
NJ.gov list (these are the people we will be pritning out paychecks for)
Phil Murphy
50(hours)
20(pay rate)
yes(holiday yes/no)
Chris Christie
30
10
No
Jon Corzine
50
10
No
Richard Codey
50
20
yes
Jim McGreevey
50
10
No
Richard Codey
30
10
No
John O. Bennett
50
10
yes
John Farmer Jr.
50
20
No
Donald DiFrancesco
30
10
No
Christine Todd Whitman
50
10
yes
James Florio
30
10
No
Thomas Kean
50
10
yes
Brendan Byrne
50
20
No
William T. Cahill
50
I really need the help please and thankyou!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
