Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. /*
  2. * Author: Jennifer Blom
  3. * Assignment #3
  4. * Calculate net pay after taking out medicare and Social security from the gross pay.
  5. */
  6.  
  7. package ProgramAssignment3;
  8.  
  9. import javax.swing.*;
  10. import java.util.*;
  11.  
  12. public class Main {
  13.  
  14. private static double SHIFT_RATE = 1.25;
  15. private static double WEEKEND_RATE = 1.50;
  16. private static double SS_TAX_PERCENT = .062;
  17. private static double MEDI_TAX_PERCENT = .0145;
  18. private static double socialSecurityWithholding;
  19. private static double netPay;
  20.  
  21. public static void main(String[] args) {
  22.  
  23. GetInputData();
  24. }
  25. public static void GetInputData() {
  26. // Create an instance of Scanner so I can get input from the keyboard
  27. Scanner keyboard = new Scanner(System.in);
  28. // input of variables first will display a prompt next gets input
  29. System.out.println("Employee Name: ");
  30. String employeeName = keyboard.nextLine();
  31. System.out.println("Enter Hourly Rate: ");
  32. double hourlyRate = keyboard.nextDouble();
  33. System.out.println("Enter Regular Hours: ");
  34. double regularHours = keyboard.nextDouble();
  35. System.out.println("Enter Overtime Hours: ");
  36. double overtimeHours = keyboard.nextDouble();
  37. System.out.println("Enter Shift Hours: ");
  38. double shiftHours = keyboard.nextDouble();
  39. System.out.println("Enter Weekend Hours: ");
  40. double weekendHours = keyboard.nextDouble();
  41.  
  42. double regularPay = regularHours * hourlyRate;
  43. double overtimePay = overtimeHours * (hourlyRate * 1.5);
  44. double shiftPay = shiftHours * SHIFT_RATE;
  45. double weekendPay = weekendHours * WEEKEND_RATE;
  46.  
  47. double grossPay = CalculateGrossPay(regularPay, overtimePay, shiftPay, weekendPay);
  48. double socialSecurityWithholding = CalculateSocSec(grossPay);
  49. double medicareWitholding = CalculateMedicare(grossPay);
  50. double netPay = CalculateNetPay(socialSecurityWithholding, medicareWitholding);
  51.  
  52. PrintResults(employeeName, regularHours, overtimeHours, shiftHours, weekendHours, hourlyRate, regularPay, overtimePay, shiftPay, weekendPay, grossPay, medicareWithholding, socialSecurityWithholding, netPay);
  53. }
  54.  
  55.  
  56. public static double CalculateGrossPay(double regularPay, double overtimePay, double shiftPay, double weekendPay){
  57. double grossPay = regularPay + overtimePay + shiftPay + weekendPay;
  58. return grossPay;
  59. }
  60.  
  61. public static double CalculateSocSec(double grossPay){
  62. socialSecurityWithholding = grossPay * SS_TAX_PERCENT;
  63. }
  64.  
  65. public static double CalculateMedicare(double grossPay){
  66. double medicareWithholding = grossPay * MEDI_TAX_PERCENT;
  67. return medicareWithholding;
  68. }
  69. public static double CalculateNetPay(double grossPay, double medicareWithholding){
  70. netPay = grossPay - (socialSecurityWithholding + medicareWithholding);
  71. }
  72.  
  73. public static void PrintResults() {
  74. //print the results to screen.
  75. System.out.println();
  76. System.out.println("Employee: " + employeeName);
  77. System.out.println("Regular hours worked: " + regularHours);
  78. System.out.println("Overtime Hours Worked: " + overtimeHours);
  79. System.out.println("Shift Hours Worked: " + shiftHours);
  80. System.out.println("Weekend Hours Worked: " + weekendHours);
  81. System.out.println("Hourly Rate: " + hourlyRate);
  82. System.out.println("Regular pay: " + regularPay);
  83. System.out.println("Overtime pay: " + overtimePay);
  84. System.out.println("Shift pay: " + shiftPay);
  85. System.out.println("Weekend pay: " + weekendPay);
  86. System.out.println("Gross pay: " + grossPay);
  87. System.out.println("Medicare Withholding: " + medicareWithholding);
  88. System.out.println("Social Security: " + socialSecurityWithholding);
  89. System.out.println();
  90. System.out.println("Net Pay: " + netPay);
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement