Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. import java.util.Scanner;
  2. /**
  3. * Activity2PayStub class is part of Lab 3 and
  4. * creates a simple pay stub.
  5. *
  6. * @author Zachary Steele
  7. * @version 9-19-2017
  8. */
  9. public class Activity2PayStub
  10. {
  11. public static final double OVERTIME_FACTOR = 1.5;
  12. public static final double SS_TAX = .1;
  13. public static final double FED_TAX = .2;
  14. /**
  15. * It all starts with the main method.
  16. *
  17. * @param args command-line arguments (not used)
  18. */
  19. public static void main(String[] args)
  20. {
  21. Scanner kb = new Scanner(System.in);
  22.  
  23. System.out.print("Enter your name: ");
  24. String name = kb.nextLine();
  25.  
  26. System.out.print("Enter your Social Security Number (with hyphens): ");
  27. String social = kb.nextLine();
  28.  
  29. System.out.print("Enter your regular hours worked (not overtime): ");
  30. int regh = kb.nextInt();
  31.  
  32. System.out.print("Enter your overtime hours worked: ");
  33. int overh = kb.nextInt();
  34.  
  35. System.out.print("Enter your hourly pay rate: ");
  36. double rate = kb.nextDouble();
  37.  
  38.  
  39.  
  40. double regPay = regh * rate;
  41. double overRate = rate * OVERTIME_FACTOR;
  42. double overPay = overRate * overh;
  43. double grossPay = regPay + overPay;
  44. double ssTaxDeduction = grossPay * SS_TAX;
  45. double incomePostSS = grossPay - ssTaxDeduction;
  46. double fedTax = incomePostSS * FED_TAX;
  47. double netPay = incomePostSS - fedTax;
  48.  
  49.  
  50.  
  51. String format = "Name: %-37s SSN: %-11s\n";
  52. String format1 = "Regular Hours: %-8d Reg Rate: "
  53. + "$%-8.2f Reg Pay: $%-8.2f\n";
  54. String format2 = "Overtime Hours: %-8dOT Rate: "
  55. + "$%-8.2f OT Pay: $%-8.2f\n";
  56. String format3 = "Gross Pay: $%-8.2f\n";
  57. String format4 = "SS Withholding: $%-8.2f\n";
  58. String format5 = "Federal Tax: $%-8.2f\n";
  59. String format6 = "Net Pay: $%-8.2f\n";
  60.  
  61. System.out.print("______________________________________"
  62. + "___________________________\n");
  63. System.out.printf(format, name, social);
  64. System.out.printf(format1, regh, rate, regPay);
  65. System.out.printf(format2, overh, overRate, overPay);
  66. System.out.printf(format3, grossPay);
  67. System.out.printf(format4, ssTaxDeduction);
  68. System.out.printf(format5, fedTax);
  69. System.out.printf(format6, netPay);
  70. System.out.println("____________________________________"
  71. + "_____________________________");
  72. }
  73. /**
  74. * It all starts with the main method.
  75. */
  76.  
  77. public void getInput(Scanner keyboard)
  78. {
  79.  
  80. }
  81.  
  82. /**
  83. * It all starts with the main method.
  84. */
  85.  
  86. public void calculate()
  87. {
  88.  
  89. }
  90.  
  91. /**
  92. * It all starts with the main method.
  93. */
  94.  
  95. public void printPayStub()
  96. {
  97.  
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement