Advertisement
Guest User

brbrbrbrb

a guest
Sep 15th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.71 KB | None | 0 0
  1. import java.util.Scanner;
  2. /**
  3. *Activity1PayStub class is part of Lab 3 and
  4. *creates a simple pay stub.
  5. *
  6. * @author Ethan Carr
  7. * @version 9/9/2014
  8. */
  9. public class Activity1PayStub
  10. {
  11. public static final
  12. double OVERTIME_FACTOR = 1.5;
  13. double OVERTIME_RATE = 1.5;
  14. double SS_RATE = .1;
  15. double TAX_RATE = .2;
  16. /**
  17. *It all starts with the main method.
  18. *
  19. * @param args command-line arguments (not used)
  20. */
  21. public static void main(String[] args)
  22. {
  23. String name;
  24. String ssn;
  25. int hours;
  26. int overtime;
  27. double payRate;
  28. double regularPay;
  29. double overtimeRate;
  30. double overtimePay;
  31. double grossPay;
  32. double socialSecurityWitholding;
  33. double federalTax;
  34. double netPay;
  35.  
  36. Scanner keyboard = new Scanner(System.in);
  37.  
  38. System.out.print("What is your name? ");
  39. name = keyboard.nextLine();
  40.  
  41. System.out.print("What is your social security number? ");
  42. ssn = keyboard.nextLine();
  43.  
  44. System.out.print("How many regular (not overtime) hours did you work this week? ");
  45. hours = keyboard.nextInt();
  46.  
  47. System.out.print("How many overtime hours did you work this week? ");
  48. overtime = keyboard.nextInt();
  49.  
  50. System.out.print("What is your hourly pay rate? ");
  51. payRate = keyboard.nextDouble();
  52.  
  53. regularPay = hours * payRate;
  54.  
  55. overtimeRate = payRate * 1.5;
  56.  
  57. overtimePay = overtimeRate * overtime;
  58.  
  59. grossPay = regularPay + overtimePay;
  60.  
  61. socialSecurityWitholding = grossPay * .1;
  62.  
  63. federalTax = (grossPay - socialSecurityWitholding) * .2;
  64.  
  65. netPay = grossPay - socialSecurityWitholding - federalTax;
  66.  
  67. System.out.println("____________________________________________________________");
  68. String format = "Name: %-37s SSN: %-11s\n";
  69. System.out.printf(format, name, ssn);
  70. format = "Regular Hours: %-8d Reg Rate: $%-8.2f Reg Pay: $%-8.2f\n";
  71. System.out.printf(format, hours, payRate, regularPay);
  72. format = "Overtime Hours: %-8dOT Rate: $%-8.2f OT Pay: $%-8.2f\n";
  73. System.out.printf(format, overtime, overtimeRate, overtimePay);
  74. format = "Gross Pay: $%-8.2f\n";
  75. System.out.printf(format, grossPay);
  76. format = "SS Withholding: $%-8.2f\n";
  77. System.out.printf(format, socialSecurityWitholding);
  78. format = "Federal Tax: $%-8.2f\n";
  79. System.out.printf(format, federalTax);
  80. format = "Net Pay: $%-8.2f\n";
  81. System.out.printf(format, netPay);
  82. System.out.println("____________________________________________________________");
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement