Categories
Java

Payroll Program Sorting Salary in Descending Order in Java

A simple payroll program that I wrote using Java that uses a one-dimensional array and it’s sorted the salary in descending order. 

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/

Sample Program Output

Program Listing

package test;

import java.util.Scanner;

public static void main(String[] args) {
     Scanner input = new Scanner (System.in);
      int employees = 0;
      int num = 6; 
      int n, temp;
      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( "WELCOME TO THE PAYROLL SYSTEM");
        System.out.println("");
           for (int i = 1; i == 1;)
       {
         System.out.println( "Enter the Name of Employee :");
         names[employees] = keyboard.next();


         System.out.println( "Enter the rate for Employee : ");
         rate[employees] = keyboard.nextInt();


         System.out.println( "Enter the days worked for Employee : ");
         days[employees] = keyboard.nextInt();

         System.out.println("Do you want to enter again your employees? [1-Yes / 2-No] : ");
          i = input.nextInt();
          employees++;
      }
 System.out.println( "Here is the gross pay for each employee:");
      for (int i = 0; i < employees; i++)
      {
        grossPay[i] = days[i] * rate[i];
        if ( grossPay[i] < 10000 )
         {
          System.out.println("The gross pay for " + names[i] +
                            ": $" + grossPay[i] + ". Less than 10k");
         }
         else{
          System.out.println("The gross pay for " + names[i] +
                            ": $" + grossPay[i] + ". Greater than 10k");
        }

      }
    // Bubble Sort of Gross Pay of the Employees here
      for (int i = 0; i < employees; i++) 
        {
            for (int j = i + 1; j < employees; j++) 
            {
                if (grossPay[i] < grossPay[j]) 
                {
                    temp = grossPay[i];
                    grossPay[i] = grossPay[j];
                    grossPay[j] = temp;
                }
            }
        }
        System.out.print("\n\n");
        System.out.print("Descending Order of the Salaries of the Employees");
        System.out.print("\n\n");
        for (int i = 0; i < employees - 1; i++) 
        {
            System.out.print(grossPay[i] + ",");
        }
        System.out.print(grossPay[employees - 1]);

}

public class hello {

} // End of Code