Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program : This is a program wrote for my fetac level 6 java programming
- // for calculating the wages of 10 employees to work out
- // tax, P.R.S.I, netpay, grosspay
- // Author : keith O'Sullivan
- // Date : 22/01/2010
- // Version : 1.0
- import java.text.*;
- class wagesassignment{
- public static void main (String[] args){
- DecimalFormat df = new DecimalFormat("#.##");
- // this section is defining the variable for person 1 to 10 name
- String [] emp;
- emp = new String [10];
- // this section is defining the array for the grosspay
- double [] grosspay;
- grosspay = new double [10];
- // this section is defining the variable for person 1 to 10 of their hours worked
- double [] hours;
- hours = new double [10];
- // this section is defining the variable for person 1 to 10 of their hourly rate
- double [] rate;
- rate = new double [10];
- // this section is defining the variable for person 1 to 10 rate of tax
- double [] tax;
- tax = new double [10];
- // this section is defining the variable for person 1 to 10 rate of prsi
- double [] prsi;
- prsi = new double [10];
- // this section is defining the variable for person 1 to 10 rate of netpay
- double [] netpay;
- netpay = new double [10];
- int count=1;
- // this is the loop command which will loop this section 10 times once for each employee
- // so basically this asks the same questions 10 times once for every employee
- while (count < 11) {
- // this section asks the user to input the name, hours worked and rate of pay for employees 1 - 10
- System.out.print ("\n\nPlease input the name of employee "+count+": ");
- emp[0]= Keyboard.readString(); // read in an String
- System.out.print ("\n\nPlease input the number of hours "+emp+count+" worked: ");
- hours[0] = Keyboard.readDouble () ; // read in an double
- System.out.print ("\n\nPlease input the rate of pay for "+emp+count+": ");
- rate[0] = Keyboard.readDouble () ; // read in an double
- // this section does all the math involved including tax, grosspay, netpay and prsi
- grosspay[0] = hours[0] * rate[0];
- if (grosspay[0] < 301)
- {tax[0] = grosspay[0] * 20 / 100 ;}
- else
- {
- tax[0] = grosspay[0] - 300 * 40 /100 + 60;
- };
- prsi[0] = grosspay[0] * 9 / 100;
- netpay[0] = grosspay[0] - tax[0] - prsi[0];
- //this part increases the count value by one which simply increases the loop count by one
- count++;
- }
- //---------------------------------------table-printout----------------------------------------------------
- System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
- System.out.print(" ----------------------------------------------------------------------------------");
- System.out.print("\n|\tname\t|\thours\t|\trate\t| grosspay |\ttax\t|\tprsi\t|\tnetpay\t|");
- System.out.print(" \n----------------------------------------------------------------------------------");
- System.out.print("\n|\t"+emp[0]+"\t|\t"+hours[0]+"\t|\t"+rate[0]+"\t|\t"+df.format(grosspay[0])+"\t|\t"+df.format(tax[0])+"\t|\t"+df.format(prsi[0])+"\t|\t"+df.format(netpay[0])+"\t|");
- System.out.print("\n|\t"+emp[1]+"\t|\t"+hours[1]+"\t|\t"+rate[1]+"\t|\t"+df.format(grosspay[1])+"\t|\t"+df.format(tax[1])+"\t|\t"+df.format(prsi[1])+"\t|\t"+df.format(netpay[1])+"\t|");
- System.out.print("\n|\t"+emp[2]+"\t|\t"+hours[2]+"\t|\t"+rate[2]+"\t|\t"+df.format(grosspay[2])+"\t|\t"+df.format(tax[2])+"\t|\t"+df.format(prsi[2])+"\t|\t"+df.format(netpay[2])+"\t|");
- System.out.print("\n|\t"+emp[3]+"\t|\t"+hours[3]+"\t|\t"+rate[3]+"\t|\t"+df.format(grosspay[3])+"\t|\t"+df.format(tax[3])+"\t|\t"+df.format(prsi[3])+"\t|\t"+df.format(netpay[3])+"\t|");
- System.out.print("\n|\t"+emp[4]+"\t|\t"+hours[4]+"\t|\t"+rate[4]+"\t|\t"+df.format(grosspay[4])+"\t|\t"+df.format(tax[4])+"\t|\t"+df.format(prsi[4])+"\t|\t"+df.format(netpay[4])+"\t|");
- System.out.print("\n|\t"+emp[5]+"\t|\t"+hours[5]+"\t|\t"+rate[5]+"\t|\t"+df.format(grosspay[5])+"\t|\t"+df.format(tax[5])+"\t|\t"+df.format(prsi[5])+"\t|\t"+df.format(netpay[5])+"\t|");
- System.out.print("\n|\t"+emp[6]+"\t|\t"+hours[6]+"\t|\t"+rate[6]+"\t|\t"+df.format(grosspay[6])+"\t|\t"+df.format(tax[6])+"\t|\t"+df.format(prsi[6])+"\t|\t"+df.format(netpay[6])+"\t|");
- System.out.print("\n|\t"+emp[7]+"\t|\t"+hours[7]+"\t|\t"+rate[7]+"\t|\t"+df.format(grosspay[7])+"\t|\t"+df.format(tax[7])+"\t|\t"+df.format(prsi[7])+"\t|\t"+df.format(netpay[7])+"\t|");
- System.out.print("\n|\t"+emp[8]+"\t|\t"+hours[8]+"\t|\t"+rate[8]+"\t|\t"+df.format(grosspay[8])+"\t|\t"+df.format(tax[8])+"\t|\t"+df.format(prsi[8])+"\t|\t"+df.format(netpay[8])+"\t|");
- System.out.print("\n|\t"+emp[9]+"\t|\t"+hours[9]+"\t|\t"+rate[9]+"\t|\t"+df.format(grosspay[9])+"\t|\t"+df.format(tax[9])+"\t|\t"+df.format(prsi[9])+"\t|\t"+df.format(netpay[9])+"\t|");
- System.out.print("\n -----------------------------------------------------------------------------------");
- }
- }
Add Comment
Please, Sign In to add comment