Here is the code that is being shared with us by my good friend and fellow software engineer Sir Jake Macalig-og which I modify and improve that will compute the salary of the employees and sort the salary of the employees from highest to lowest. We wrote this code will some difficulty because there is no existing code on the Internet so we have to write it from scratch.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com
I am also a book author you can purchase my books on computer programming and information technology in the following links below.
https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/
Program Listing
payroll.java
package test;
import java.util.Scanner;
public class payroll {
public static void main(String[] args) { Scanner input = new Scanner (System.in); int employees = 0;
int num = 6;
int temp=0;
String tempName;
int[] grossPay = new int[100];
//arrays
String[] names = new String [100]; int[] days = new int[100];
int[] rate = new int[100];
int[] wages;
//scanner Scanner keyboard = new Scanner(System.in);
System.out.println( "EMPLOYEES PAYROLL SYSTEM"); System.out.println(); System.out.println("It Displays Highest and Lowest Salary of Employees"); System.out.println();
for (int i = 1; i == 1;) { keyboard.nextLine(); System.out.print( "Enter the Name of Employee : ");
names[employees] = keyboard.nextLine();
System.out.print( "Enter the daily rate : ");
rate[employees] = keyboard.nextInt();
System.out.print( "Enter the days worked : ");
days[employees] = keyboard.nextInt();
System.out.print("Do you want to enter again your employees? [1-Yes / 2-No] : ");
i = input.nextInt();
employees++;
}
for (int i = 0; i < employees; i++) { grossPay[i] = days[i] * rate[i]; }
// Bubble Sort of Gross Pay of the Employees together with its Name here
for (int i = 0; i < employees - 1; i++) {
for (int j = i + 1; j < employees; j++) {
if (grossPay[i] < grossPay[j]) {
temp = grossPay[i]; grossPay[i] = grossPay[j]; grossPay[j] = temp;
tempName = names[i]; names[i] = names[j]; names[j] = tempName; } } }
System.out.print("\n\n"); System.out.print("\tHighest To Lowest Salary of Employees");
System.out.print("\n\n");
for (int i = 0; i < employees; i++){ System.out.println(names[i] + ":" + grossPay[i]);
}
System.out.println(); System.out.println("\tEnd of Program"); System.out.println();
}
} // End of Code