Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. import java.text.NumberFormat;
  2. import java.util.Scanner;
  3.  
  4. class Payroll
  5. {
  6. public static void main(String [] args){
  7. //variables; hours, dependant(s), overtime
  8. int hours;
  9. Scanner console = new Scanner(System.in);
  10. System.out.println("Please enter the amount of hours worked ");
  11. hours = console.nextInt();
  12. int dependant;
  13. System.out.println("Please enter the amount of dependant ");
  14. dependant = console.nextInt();
  15. Scanner scan = new Scanner(System.in);
  16. int overtime;
  17. System.out.println("Please enter the amount of overtime you done for the week ");
  18. overtime = console.nextInt();
  19.  
  20. //taxes and income
  21. double grosspay;
  22. double weekpay;
  23. double FederalTax;
  24. double SocialSecurityTax;
  25. double StateIncomeTax;
  26.  
  27. //payrate, taxes, union charge; My constants
  28. double rate = 18.28;
  29. double socialsecuritytax = .06;
  30. double federalincometax = .13;
  31. double stateincometax = .05;
  32. double unionduecharge = 11;
  33.  
  34. //Calculations
  35.  
  36. if(hours > 40)
  37. {
  38. grosspay = (rate * 40) + (1.5 * rate * overtime);
  39. }
  40.  
  41. else
  42. {
  43. grosspay = rate * hours;
  44. }
  45.  
  46.  
  47. if(dependant > 2)
  48. {
  49. grosspay = (rate * 40) + (1.5 * rate * overtime) - 35;
  50. }
  51. else
  52. {
  53. grosspay = (rate * 40) + (1.5 * rate * overtime) - 11;
  54. }
  55.  
  56. weekpay = grosspay - (grosspay * federalincometax) - (
  57. grosspay * socialsecuritytax) -
  58. (grosspay * stateincometax) - unionduecharge;
  59. FederalTax = grosspay * federalincometax;
  60. SocialSecurityTax = grosspay * socialsecuritytax;
  61. StateIncomeTax = grosspay * stateincometax;
  62.  
  63. NumberFormat format = NumberFormat.getCurrencyInstance();
  64.  
  65.  
  66. do {
  67. System.out.println("You enter a negative number for hours.");
  68. }while (hours<0);
  69.  
  70. do{
  71. System.out.println("You enter a negative dependant.");
  72. }while(dependant<0);
  73.  
  74. do{
  75. System.out.println("You enter negative overtime.");
  76. }while(overtime<0);
  77.  
  78.  
  79. if(hours <=100 && dependant<=2 && overtime <=60){
  80.  
  81. System.out.println("This is your gross pay "
  82. +format.format(grosspay));
  83. System.out.println("Federal Tax with holding "
  84. +format.format(FederalTax));
  85. System.out.println("Social Security Tax with holding "
  86. +format.format(SocialSecurityTax));
  87. System.out.println("State Income Tax with holding "
  88. +format.format(StateIncomeTax));
  89. System.out.println("This is your week pays after deductions "
  90. +format.format(weekpay));
  91. }
  92. else if (hours>100){
  93. System.out.println("You enter too many hours.");
  94. }
  95. else if (dependant>2){
  96. System.out.println("You enter too many dependants.");
  97. }
  98. else if(overtime>=60){
  99. System.out.println("You enter too many overtime.");
  100.  
  101. }
  102.  
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement