Hello,
I've been stuck on this homework assignment for some time now, and tried looking for possible solutions. The assignment goes like this...Write a Payroll class that uses the following arrays as fields:
employeeID - An array of seven integers to hold employee identification numbers.
The array should be initialized with the following numbers:
5658845 4520125 7895122 8777541
8451277 1302850 7580489
hours - An array of seven integers to hold the number of hours worked by each employee.
payRate - An array of seven doubles to hold each employee's hourly pay rate.
wages - An array of seven doubles to hold each employee's gross wages.
The class should relate the data in each array through the subscripts.
For example, the number in element 0 of the hours array should be the number of hours worked by the employee
whose identification number is stored in element 0 of the employeeID array.
That same employee's pay rate should be stored in element 0 of the payRate array.
In addition to the appropriate accessor and mutator methods,
the class should have a method that accepts an employee's identification number
as an argument and returns the gross pay for that employee.
Demonstrate the class in a complete program that displays each employee number
and asks the user to enter that employee's hours and pay rate.
It should then display each employee's identification number and gross wages.
Input Validation: Do not accept negative values for hours or numbers less than 6.0 for a pay rate.
My problem with this program is that everytime I try to print the employee ID's or the wages, I get hashcode or something like it (#[I1a77cdc or something like that). I tried using the toString method, but it lists all of the values, when I'm trying to display one at a time. Here is the code for the class:
This is the demo program to list the ID's. I've been messing with it for some time, and right now I just want it to display values. Any help is appreciated!// moduleArray class public class moduleArray { final int NUM_EMPLOYEES = 7; int[] employeeID = {5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 7580489}; int[] hours = new int[NUM_EMPLOYEES]; double[] payRate = new double[NUM_EMPLOYEES]; double[] wages = new double[NUM_EMPLOYEES]; // setHours method public void setHours(int[] time) { hours = time; } // setPayRate method public void setPayRate(double[] pay) { payRate = pay; } //getEmployeeID method public int[] getEmployeeID() { return employeeID; } // getWages method public double[] getWages() { wages = hours[] * payRate[]; return wages; } }
import java.util.Scanner; public class moduleArrayDemo { public static void main(String[] args) { final int NUM_EMPLOYEES = 7; int[] ID = new int[NUM_EMPLOYEES]; int[] time = new int[NUM_EMPLOYEES]; double[] pay = new double[NUM_EMPLOYEES]; Scanner keyboard = new Scanner(System.in); moduleArray[] employee = new moduleArray[NUM_EMPLOYEES]; for (int i = 0; i < employee.length; i++) employee[i] = new moduleArray(); for (int i = 0; i < 7; i++) System.out.println(employee[i]); } }