Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. // the scanner is activated.
  4. public class PayStub {
  5. /*
  6. @author Benicio Liu
  7. @version 9/19
  8. */
  9. public static void main(String[] args) {
  10. // public static void is used due to being public.
  11. Scanner sc = new Scanner(System.in);
  12.  
  13. String employeeName;
  14. int startMonth;
  15. int startYear;
  16. int hoursWorked;
  17. String jobTitle;
  18. double hourlyPayrate;
  19. int numMonthWorked;
  20.  
  21. // declaration of all variables.
  22.  
  23. int currentMonth = 9;
  24. int currentYear = 2018;
  25.  
  26. // set variable.
  27.  
  28. System.out.print("Enter your Fullname: ");
  29. employeeName = sc.nextLine();
  30.  
  31. System.out.print("Enter your Anniversary Month(1-12): ");
  32. startMonth = sc.nextInt();
  33.  
  34. System.out.print("Enter your Anniversary Year: ");
  35. startYear = sc.nextInt();
  36.  
  37. System.out.print("Enter your hours worked this pay period(0-350): ");
  38. hoursWorked = sc.nextInt();
  39.  
  40. System.out.println("Enter your Job Title: ");
  41. jobTitle = sc.nextLine();
  42.  
  43. System.out.print("Enter your pay rate: ");
  44. hourlyPayrate = sc.nextDouble();
  45. System.out.println("");
  46.  
  47. // inputting into scanner to get output.
  48.  
  49.  
  50.  
  51.  
  52. System.out.println("==========================================");
  53. System.out.println(" Gekko & Co.\n");
  54. System.out.println(" \"$\"");
  55. System.out.println(" ~~~");
  56. System.out.println(" / \\ `.");
  57. System.out.println(" / \\ /");
  58. System.out.println(" /_ _ _ \\/\n");
  59. System.out.println("------------------------------------------");
  60.  
  61. // drawn logo.
  62.  
  63. System.out.println("Pay Period: "+ currentMonth + "/" + currentYear);
  64.  
  65. System.out.println("Name: "+ employeeName);
  66.  
  67. System.out.println("Title: "+ jobTitle);
  68.  
  69. System.out.println("Anniversary: "+ startMonth + "/" + startYear);
  70.  
  71. numMonthWorked = ((currentYear - startYear) * 12) + (currentMonth - startMonth);
  72. System.out.println("Months Worked: "+ numMonthWorked + " months");
  73. double vacationHours = numMonthWorked * 8.25;
  74. System.out.print("Vacation hours: ");
  75. System.out.printf("%.2f\n", vacationHours);
  76.  
  77. // total output of the statements.
  78. System.out.println("------------------------------------------");
  79.  
  80.  
  81. double grossPay = hoursWorked * hourlyPayrate;
  82. System.out.print("Gross Pay: $");
  83. System.out.printf("%7.2f\n", grossPay);
  84.  
  85. double retirement = grossPay * 0.052;
  86. System.out.print("Retirement: $");
  87. System.out.printf("%7.2f\n", retirement);
  88.  
  89.  
  90. double GR = grossPay - retirement;
  91. System.out.print("Tax: $");
  92. double tax = GR * 0.28;
  93. System.out.printf("%7.2f\n", tax);
  94.  
  95. System.out.println("--------------------------");
  96.  
  97. double netPay = GR - tax;
  98. System.out.print("netPay: $");
  99. System.out.printf("%7.2f\n", netPay);
  100.  
  101. //calculations done
  102.  
  103. }
  104.  
  105.  
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement