0% found this document useful (0 votes)
30 views

Source Code:: Pancho, Ciandra V. Data Structures-Array IT21S2 CITE004

The document contains the source code for a Java program that calculates employee salaries using a 2D array. It prompts the user to enter the number of employees, then uses a for loop to input each employee's ID number, hourly rate, days worked into the array. It calculates their salary by multiplying rate by days worked and stores it in the array. It then outputs the employee data including ID, rate, days worked and salary for each employee.

Uploaded by

CIANDRA PANCHO
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Source Code:: Pancho, Ciandra V. Data Structures-Array IT21S2 CITE004

The document contains the source code for a Java program that calculates employee salaries using a 2D array. It prompts the user to enter the number of employees, then uses a for loop to input each employee's ID number, hourly rate, days worked into the array. It calculates their salary by multiplying rate by days worked and stores it in the array. It then outputs the employee data including ID, rate, days worked and salary for each employee.

Uploaded by

CIANDRA PANCHO
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

PANCHO, CIANDRA V.

DATA STRUCTURES-ARRAY

IT21S2 CITE004

SOURCE CODE:

package dataStructures;

import java.util.Scanner;

public class Salary {


public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

int empNo=0;
int i=0;
int j=0;

System.out.print("Enter how many employees: ");


empNo = scan.nextInt();

System.out.println("\nFILL THE FOLLOWING");

//DATA user INPUT


int[][] employee = new int[10][10];
for(int num=0;num<empNo;num++) {
System.out.print("\nEmployee NO.: ");
i=scan.nextInt();
employee[i][i]=i;

System.out.print("RatePerHour: ");
employee[i][i+1]=scan.nextInt();

System.out.print("Days Worked: ");


employee[i][i+2]=scan.nextInt();

//COMPUTATION OF SALARY
//comlumn 4 column2 column3
employee[i][i+3]=employee[i][i+1]*employee[i][i+2];
}

System.out.println("\nEMP NO.\t Rate Per Hour\t Days Worked\tSalary");


for(j=1;j<empNo+1;j++) {
System.out.println(" ");
System.out.println(employee[j][j]+"\t\t"+employee[j][j+1]+"\t\t"
+employee[j][j+2]+"\t "+employee[j][j+3]);
}
}

}
OUTPUT:

You might also like