Advertisement
Guest User

incomeTaxCalculator

a guest
May 20th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. package chapter_3;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ComputeTax {
  6.  
  7. public static void main(String[] args) {
  8. // Compute a person's income tax
  9.  
  10. Scanner input = new Scanner(System.in);
  11. //Prompt user for filing status
  12. System.out.println("Enter your filing status:");
  13. System.out.println("0 - Single");
  14. System.out.println("1 - Maried/Joint Filing");
  15. System.out.println("2 - Married/Separate Filing");
  16. System.out.println("3 - Head of Household");
  17.  
  18. //Get user filing status
  19. int filingStatus = input.nextInt();
  20.  
  21. //Prompt user for taxable income
  22. System.out.println("\nWhat is your taxable income?");
  23. //Get user taxable income
  24. double income = input.nextDouble();
  25. //Set taxable Income variable
  26. double taxableIncome = 0;
  27.  
  28. //Calculate taxable income for single filers
  29. if (filingStatus == 0) {
  30. if (income < 8350) {
  31. double taxableIncome = income * .1;
  32. }
  33. else if (income <= 33950) {
  34. double taxableIncome = 8350 * 0.10 + (income - 8350) * 0.15;
  35. }
  36. else if (income <= 82250) {
  37. double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 + (income - 33950) * 0.25;
  38. }
  39. else if (income <= 171550) {
  40. double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
  41. (82250 - 33950) * 0.25 + (income - 82250) * 0.28;
  42. }
  43. else if (income <= 372950) {
  44. double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
  45. (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (income -372950) * .33;
  46. }
  47. else {
  48. double taxableIncome = 8350 * 0.10 + (33950 - 8350) * 0.15 +
  49. (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + (372950 - 171550) * .33 +
  50. (income - 372950) * .35;
  51. }
  52.  
  53. }
  54. else {
  55. System.out.println("Not filing as single");
  56. }
  57.  
  58. System.out.print(taxableIncome);
  59.  
  60. input.close();
  61.  
  62.  
  63. }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement