Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package lab4;
  7. import java.util.Scanner;
  8. /**
  9. *
  10. * @author x00101556
  11. */
  12. public class Lab4 {
  13. public static void main(String[] args) {
  14. Scanner scan = new Scanner (System.in);
  15.  
  16. System.out.print("Please enter your employee id number: ");
  17. int empNum = scan.nextInt();
  18.  
  19. System.out.print("Please enter your gross pay: ");
  20. double grossPay = scan.nextInt();
  21.  
  22. System.out.print("Please enter s for single or m for married: ");
  23. String status = scan.next();
  24. char inputChar = status.charAt(0);
  25.  
  26. scan.nextLine();
  27. System.out.print("Please enter your address: ");
  28. String address = scan.nextLine();
  29.  
  30.  
  31. final double SINGLE_TAX = 0.20;
  32. final double MARRIED_TAX = 0.23;
  33. double totalTax;
  34. double netPay;
  35.  
  36. System.out.println();
  37. if (grossPay >= 50000 && inputChar == 'm'){
  38. totalTax = grossPay - 20000;
  39. totalTax = grossPay * MARRIED_TAX;
  40. System.out.println("You are married.");
  41. System.out.println("You're employee number is: " + empNum);
  42. System.out.println("You're address is: " + address);
  43. System.out.println("You're total gross pay is: €" + grossPay);
  44. System.out.println("You're total tax due is: €" + totalTax);
  45. netPay = grossPay - totalTax;
  46. System.out.println("You're total net pay is: €" + netPay);
  47. }
  48.  
  49. if (grossPay >= 50000 && inputChar == 's'){
  50. totalTax = grossPay - 20000;
  51. totalTax = grossPay * SINGLE_TAX;
  52. System.out.println("You are single.");
  53. System.out.println("You're employee number is: " + empNum);
  54. System.out.println("You're address is: " + address);
  55. System.out.println("You're total gross pay is: €" + grossPay);
  56. System.out.println("You're total tax due is: €" + totalTax);
  57. netPay = grossPay - totalTax;
  58. System.out.println("You're total net pay is: €" + netPay);
  59. }
  60.  
  61. if (grossPay < 50000 && inputChar == 'm'){
  62. totalTax = grossPay - 25000;
  63. totalTax = grossPay * MARRIED_TAX;
  64. System.out.println("You are married.");
  65. System.out.println("You're employee number is: " + empNum);
  66. System.out.println("You're address is: " + address);
  67. System.out.println("You're total gross pay is: €" + grossPay);
  68. System.out.println("You're total tax due is: €" + totalTax);
  69. netPay = grossPay - totalTax;
  70. System.out.println("You're total net pay is: €" + netPay);
  71. }
  72.  
  73. if (grossPay < 50000 && inputChar == 's'){
  74. totalTax = grossPay - 25000;
  75. totalTax = grossPay * SINGLE_TAX;
  76. System.out.println("You are single.");
  77. System.out.println("You're employee number is: " + empNum);
  78. System.out.println("You're address is: " + address);
  79. System.out.println("You're total gross pay is: €" + grossPay);
  80. System.out.println("You're total tax due is: €" + totalTax);
  81. netPay = grossPay - totalTax;
  82. System.out.println("You're total net pay is: €" + netPay);
  83. }
  84.  
  85. System.out.println();
  86. System.out.print("For security reasons please enter a password: ");
  87. String passwordOne = scan.nextLine();
  88.  
  89. System.out.print("Please re-enter you're password: ");
  90. String passwordTwo = scan.nextLine();
  91.  
  92. if(passwordOne.equals(passwordTwo)){
  93. System.out.println("You're passwords match.");
  94. }else{
  95. System.out.println("You're passwords do not match.");
  96. }
  97.  
  98.  
  99. }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement