Guest User

Untitled

a guest
Jun 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.60 KB | None | 0 0
  1. //this program was lovingly written by Jason Stewart
  2.  
  3.  
  4.  
  5. import java.util.Scanner;
  6.  
  7.  
  8. public class Tax {
  9. public static void main(String[] args) {
  10. Scanner input = new Scanner(System.in); //creates scanner
  11.  
  12. System.out.print( "(Input one of the following:\n 0-Single Filer\n 2-married separately\n 3-Head of Household\nEnter the filing status: ");
  13. int status = input.nextInt();
  14.  
  15. System.out.print("Enter the taxable income: ");
  16. double income = input.nextDouble(); //enters the taxable income
  17.  
  18. double tax = 0; //placeholder for the tax
  19.  
  20. if (status == 0)
  21. {
  22. if (income <= 8350)
  23. tax = income * .10;
  24. else if (income <= 33950)
  25. tax = 8350 * .10 + (income - 8350) * 0.15;
  26. else if (income <= 82250)
  27. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
  28. else if (income <= 171550)
  29. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28;
  30. else if (income <= 372950)
  31. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28 + (income - 171550) * 0.35;
  32. else
  33. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25 + (income - 82250) * 0.28 + (income - 171550) * 0.33 + (income - 372950) * 0.35;
  34.  
  35. }
  36. if (status == 1)
  37. {
  38. if (income <= 16700)
  39. tax = income * .10;
  40. else if (income <= 67900)
  41. tax = 16700 * .10 + (income - 16700) * 0.15;
  42. else if (income <= 137050)
  43. tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25;
  44. else if (income <= 208850)
  45. tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28;
  46. else if (income <= 372950)
  47. tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28 + (income - 208850) * 0.33;
  48. else
  49. tax = 16700 * .10 + (67900 - 16700) * 0.15 + (income - 67900) * 0.25 + (income - 137050) * 0.28 + (income - 208850) * 0.33 + (income - 372950) * 0.35;
  50.  
  51. }
  52. if (status == 2)
  53. {
  54. if (income <= 8350)
  55. tax = income * .10;
  56. else if (income <= 33950)
  57. tax = 8350 * .10 + (income - 8350) * 0.15;
  58. else if (income <= 68525)
  59. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25;
  60. else if (income <= 104425)
  61. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28;
  62. else if (income <= 186475)
  63. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28 + (income - 186475) * 0.33;
  64. else
  65. tax = 8350 * .10 + (33950 - 8350) * 0.15 + (income - 68525) * 0.25 + (income - 104425) * 0.28 + (income - 186475) * 0.33 + (income - 186476) * 0.35;
  66.  
  67. }
  68. if (status == 3)
  69. {
  70. if (income <= 11950)
  71. tax = income * .10;
  72. else if (income <= 45500)
  73. tax = 11950 * .10 + (income - 11950) * 0.15;
  74. else if (income <= 117450)
  75. tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25;
  76. else if (income <= 190200)
  77. tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28;
  78. else if (income <= 372950)
  79. tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28 (income - 392950) * 0.33;
  80. else
  81. tax = 11950 * .10 + (45500 - 11950) * 0.15 + (income - 117450) * 0.25 + (income - 190200) * 0.28 + (income - 392950) * 0.33 + (income - 372951) * 0.35;
  82.  
  83. else {
  84. System.out.println("Error: Invalid status");
  85. System.exit(0);
  86. }
  87. }
  88.  
  89.  
  90. System.out.println("Tax is " + (int)(tax *100) / 100.0);
  91. }
  92. }
Add Comment
Please, Sign In to add comment