Guest User

Untitled

a guest
Jul 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. // Program : This is a program wrote for my fetac level 6 java programming
  2. // for calculating the wages of 10 employees to work out
  3. // tax, P.R.S.I, netpay, grosspay
  4.  
  5. // Author : keith O'Sullivan
  6.  
  7. // Date : 22/01/2010
  8.  
  9. // Version : 1.0
  10.  
  11. import java.text.*;
  12.  
  13. class wagesassignment{
  14.  
  15. public static void main (String[] args){
  16.  
  17. DecimalFormat df = new DecimalFormat("#.##");
  18.  
  19. // this section is defining the variable for person 1 to 10 name
  20. String [] emp;
  21. emp = new String [10];
  22.  
  23. // this section is defining the array for the grosspay
  24. double [] grosspay;
  25. grosspay = new double [10];
  26.  
  27. // this section is defining the variable for person 1 to 10 of their hours worked
  28. double [] hours;
  29. hours = new double [10];
  30.  
  31. // this section is defining the variable for person 1 to 10 of their hourly rate
  32. double [] rate;
  33. rate = new double [10];
  34.  
  35. // this section is defining the variable for person 1 to 10 rate of tax
  36. double [] tax;
  37. tax = new double [10];
  38.  
  39. // this section is defining the variable for person 1 to 10 rate of prsi
  40. double [] prsi;
  41. prsi = new double [10];
  42.  
  43. // this section is defining the variable for person 1 to 10 rate of netpay
  44. double [] netpay;
  45. netpay = new double [10];
  46.  
  47. int count=1;
  48.  
  49. // this is the loop command which will loop this section 10 times once for each employee
  50. // so basically this asks the same questions 10 times once for every employee
  51. while (count < 11) {
  52.  
  53. // this section asks the user to input the name, hours worked and rate of pay for employees 1 - 10
  54.  
  55. System.out.print ("\n\nPlease input the name of employee "+count+": ");
  56. emp[0]= Keyboard.readString(); // read in an String
  57.  
  58. System.out.print ("\n\nPlease input the number of hours "+emp+count+" worked: ");
  59. hours[0] = Keyboard.readDouble () ; // read in an double
  60.  
  61. System.out.print ("\n\nPlease input the rate of pay for "+emp+count+": ");
  62. rate[0] = Keyboard.readDouble () ; // read in an double
  63.  
  64. // this section does all the math involved including tax, grosspay, netpay and prsi
  65.  
  66. grosspay[0] = hours[0] * rate[0];
  67.  
  68. if (grosspay[0] < 301)
  69.  
  70. {tax[0] = grosspay[0] * 20 / 100 ;}
  71.  
  72. else
  73. {
  74. tax[0] = grosspay[0] - 300 * 40 /100 + 60;
  75. };
  76.  
  77.  
  78. prsi[0] = grosspay[0] * 9 / 100;
  79. netpay[0] = grosspay[0] - tax[0] - prsi[0];
  80.  
  81. //this part increases the count value by one which simply increases the loop count by one
  82. count++;
  83.  
  84. }
  85.  
  86. //---------------------------------------table-printout----------------------------------------------------
  87.  
  88. System.out.print("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
  89. System.out.print(" ----------------------------------------------------------------------------------");
  90. System.out.print("\n|\tname\t|\thours\t|\trate\t| grosspay |\ttax\t|\tprsi\t|\tnetpay\t|");
  91. System.out.print(" \n----------------------------------------------------------------------------------");
  92. 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|");
  93. 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|");
  94. 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|");
  95. 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|");
  96. 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|");
  97. 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|");
  98. 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|");
  99. 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|");
  100. 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|");
  101. 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|");
  102. System.out.print("\n -----------------------------------------------------------------------------------");
  103.  
  104.  
  105. }
  106. }
Add Comment
Please, Sign In to add comment