this is my first time on stackoverflow and I had a question.
I am to design a program that prints out payroll for 5 employees.
We are required to have one array of type int for the Employee ID...
int[ ] {100,200,300,400,500};
And a two dimensional array for the payroll... int[5][5]
We are given the Employee ID's, hrs worked and pay rate for each employee, which are to be hardcoded within the corresponding array elements.
For example
payroll[0][0]
is Employee 1's hrs worked, which in this case is 50
payroll[1][0]
is Employee 1's pay rate, which in this case is 25
payroll[2][0]
should be Employee 1's gross pay
My question is, I need to calc gross pay for each employee and store those values into the 3rd column in payroll[ ][ ]
.
Below is the code I have so far, any help would be amazing.
public class CIS131_HW5
{
public static void main(String[] args)
{
// Employee ID array
int[] ID = new int[] {100,200,300,400,500};
for (int i=0; i<ID.length; i++)
{
System.out.println(ID[i]);
}
System.out.println( "" );
// Payroll Array
int[][] payroll = new int [5][5];
int rows = 5;
int columns = 5;
// values given for hrs worked
payroll[0][0] = 50;
payroll[0][1] = 15;
payroll[0][2] = 48;
payroll[0][3] = 40;
payroll[0][4] = 40;
// values given for pay rate
payroll[1][0] = 25;
payroll[1][1] = 15;
payroll[1][2] = 27;
payroll[1][3] = 25;
payroll[1][4] = 23;
for (int i=0; i<rows; i++)
{
for(int j=0; j<columns; j++)
{
System.out.println(payroll[i][j] + " ");
}
System.out.println( "" );
}
}
}