Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is Java. I need the Pseudocode or Flowchart for this source code. Either is fine. SOURCE CODE: ==================****====================== public class Payroll { private int[]

This is Java.

I need the Pseudocode or Flowchart for this source code. Either is fine.

SOURCE CODE:

==================****======================

public class Payroll {

private int[] employeeID = {5658845, 4520125, 7895122, 8477541, 8451277, 1302850, 7580489 };

//Number of hours worked by each employee private int[] hours = new int[7];

//Employee's hourly pay rate private double[] payRate = new double[7];

//Employee's gross wages. private double[] wages = new double[7];

//accessor and mutator methods

//returns id of index public int getEmployeeID(int index) { return employeeID[index]; }

//returns hours public int getHours(int index) { return hours[index]; }

//returns payrate public double getPayRate(int index) { return payRate[index]; }

//returns wages public double getWages(int index) { return wages[index]; }

//sets ID public void setEmployeeID(int index, int ID) { employeeID[index] = ID; }

//Sets Hours public void setHours(int index, int hour) { hours[index] = hour; }

//Sets Rate public void setPayRate(int index, double payrate) { payRate[index] = payrate; }

//Sets Wages public void setWages(int index, double wage) { wages[index] = wage; }

//Gross pay for each employee with identification

public double calculateGrossPay(int theEmployeeID) { double grossPay = 0; int employeeIndex = - 1; //index of the employee for (int i = 0; i < employeeID.length; i++) { if (employeeID[i] == theEmployeeID) { employeeIndex = i; break; } } if (employeeIndex != - 1) { //gross pay for if employee was found.

int h = hours[employeeIndex]; double r = payRate[employeeIndex]; grossPay = (h * r); //calculate the gross pay } return grossPay; } }

--------------------------------------------------------------------------------------------------------------

/** * Modified java program that prompts user to enter * hours and pay rate and then prints the gross pay * to console for each employee * */ import java.text.DecimalFormat; import java.util.Scanner; public class payRollTest {

public static void main(String[] args) { //System.out.println(" Payroll Application "); Payroll payroll = new Payroll(); Scanner kb = new Scanner(System.in); //Variable declaration int hours; double payRate; double wages; //Intialize employeeid array int[] employeeID = {5658845, 4520125, 7895122, 8477541, 8451277, 1302850, 7580489 }; //Loop repeats for all 7 employees for (int i = 0; i < 7; i++) { //System.out.println("Employee :" + (i + 1) ); do { //get the hours

System.out.println("Enter the hours worked by employee number " + employeeID[i]+":"); hours = Integer.parseInt(kb.nextLine()); } while (hours < 0); payroll.setHours(i, hours); do { //get the payrate System.out.println("Enter the hourly pay rate for employee number :" + employeeID[i]+":" ); payRate = Double.parseDouble(kb.nextLine()); //print error message if rate is < 6 if(payRate<6.00) System.out.println("ERROR: Enter 6.00 or greater for pay rate: "); }while (payRate < 6.00); payroll.setPayRate(i, payRate); int empid = payroll.getEmployeeID(i); wages = payroll.calculateGrossPay(empid); payroll.setWages(i, wages); }

//Cretae a instance of decimal format to display comma //separated values DecimalFormat df=new DecimalFormat("##,###.00"); //Display each employee's identification number //and gross wages.

System.out.println(" PAYROLL DATA "); System.out.println(" ============= "); for (int i = 0; i < 7; i++) { System.out.println("\tEmployee ID: " + payroll.getEmployeeID(i)); System.out.println("\tGross pay: $" + df.format(payroll.getWages(i))); } //Exit program System.exit(0); } }

=====================****========================

Thank you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to columns 1 and 6 in the table for question

Answered: 1 week ago