Write a Java program to display the three top sales made by employees of an organization. The rows and columns represent the sales made by each employee identified by their employee number. SALES 1 SALES 2 SALES 3 101111 R 3 000 R 2 000 R 3 500 101122 R 2 500 R 5 500 R 3 500 101133 R 1 100 R 2 000 R 4 500 101144 R 1 700 R 2 700 R 2 500 101155 R 5 000 R 2 900 R 5 900 Using a Two Dimensional array produce the employee sales report, and the total sales made by each employee.
public class Main {
public static void main(String[] args) {
int [][] array = new int[5][3];
int [] Esales = {3000,2000,3500,2500,5500,3500,1100,2000,4500,1700,2700,2500,5000,2900,5900};
int x =0;
for(int k=0; k<5; k++){
for(int n=0; n<3;n++){
array[k][n] = Esales[x++];
}
}
System.out.println("-------------------------------------------------------");
System.out.println("\t\t\tEMPLOYEE SALES REPORT");
System.out.println("-----------------------------------------------------------");
System.out.println("EMPLOYEE\t\tSALES 1\t\tSALES 2\t\tSALES 3");
int [] employee = {101111, 101122, 101133,101144,101155};
int [] total = new int[5];
for(int k=0; k<5; k++){
int add = 0;
System.out.printf("%d-->\t\t",employee[k] );
for(int n=0; n<3; n++){
System.out.printf("R %d\t\t",array[k][n]);
add += array[k][n];
}
total[k] = add;
System.out.println(" ");
}
System.out.println("------------------------------------------------------------------");
System.out.println("\t\t\tEMPLOYEE TOTAL SALES");
System.out.println("--------------------------------------------------------------");
for(int k=0; k<5; k++){
System.out.printf("%d-->\t\t R %d\n",employee[k],total[k]);
}
}
}
Comments
Leave a comment