fork download
  1. import java.util.Scanner;
  2. public class Main {
  3. public static void main(String[] args) {
  4. Scanner reader = new Scanner(System.in);
  5. System.out.println("Which filing status number suits you? ");
  6. System.out.println("0. Single filer\n1. Married filing jointly\n2. Married filing seperately\n3. Head of household");
  7. System.out.println("");
  8. System.out.print("Enter the filing status: ");
  9. int status = Integer.parseInt(reader.nextLine());
  10. System.out.print("Enter the taxable income: ");
  11. double income = Double.parseDouble(reader.nextLine());
  12. if (income < 0){
  13. System.out.println("Taxable income can not be negative!");
  14. return ;
  15. }
  16. double tax = 0;
  17. if (status == 0) {
  18. if ( income <= 8350){
  19. tax = income * 0.10;
  20. } else if (income <= 33950) {
  21. tax = (8350 * 0.10) + (income-8350) * 0.15;
  22. } else if (income <= 82250) {
  23. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((income-33950) * 0.25);
  24. } else if (income <= 171550) {
  25. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((82250-33950) * 0.25) + ((income-82250) * 0.28);
  26. } else if (income <= 372950) {
  27. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((82250-33950) * 0.25) + ((171500-82250) * 0.28) + ((income-171550) * 0.33);
  28. } else if ( income >= 372951) {
  29. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((82250-33950) * 0.25) + ((171550-82250) * 0.28) + ((372950-171550) * 0.33) + ((income-372950) * 0.35);
  30. }
  31. }
  32. if (status == 1) {
  33. if ( income <= 16700){
  34. tax = income * 0.10;
  35. } else if (income <= 67900) {
  36. tax = (16700 * 0.10) + (income-16700) * 0.15;
  37. } else if (income <= 137050) {
  38. tax = (16700 * 0.10) + ((67900-16700) * 0.15) + ((income-67900) * 0.25);
  39. } else if (income <= 208850) {
  40. tax = (16700 * 0.10) + ((67900-16700) * 0.15) + ((137050-67900) * 0.25) + ((income-137050) * 0.28);
  41. } else if (income <= 372950) {
  42. tax = (16700 * 0.10) + ((67900-16700) * 0.15) + ((137050-67900) * 0.25) + ((208850-137050) * 0.28) + ((income-208850) * 0.33);
  43. } else if ( income >= 372951) {
  44. tax = (16700 * 0.10) + ((67900-16700) * 0.15) + ((137050-67900) * 0.25) + ((208850-137050) * 0.28) + ((372950-208850) * 0.33) + ((income-372950) * 0.35);
  45. }
  46. }
  47. if (status == 2) {
  48. if ( income <= 8350){
  49. tax = income * 0.10;
  50. } else if (income <= 33950) {
  51. tax = (8350 * 0.10) + (income-8350) * 0.15;
  52. } else if (income <= 68525) {
  53. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((income-33950) * 0.25);
  54. } else if (income <= 104425) {
  55. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((68525-33950) * 0.25) + ((income-68525) * 0.28);
  56. } else if (income <= 186475) {
  57. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((68525-33950) * 0.25) + ((104425-68525) * 0.28) + ((income-104425) * 0.33);
  58. } else if ( income >= 186476) {
  59. tax = (8350 * 0.10) + ((33950-8350) * 0.15) + ((68525-33950) * 0.25) + ((104425-68525) * 0.28) + ((186475-104425) * 0.33) + ((income-186475) * 0.35);
  60. }
  61. }
  62. if (status == 3) {
  63. if ( income <= 11950){
  64. tax = income * 0.10;
  65. } else if (income <= 45500) {
  66. tax = (11950 * 0.10) + (income-11950) * 0.15;
  67. } else if (income <= 117450) {
  68. tax = (11950 * 0.10) + ((45500-11950) * 0.15) + ((income-45500) * 0.25);
  69. } else if (income <= 190200) {
  70. tax = (11950 * 0.10) + ((45500-11950) * 0.15) + ((117450-45500) * 0.25) + ((income-117450) * 0.28);
  71. } else if (income <= 372950) {
  72. tax = (11950 * 0.10) + ((45500-11950) * 0.15) + ((117450-45500) * 0.25) + ((190200-117450) * 0.28) + ((income-190200) * 0.33);
  73. } else if ( income >= 372951) {
  74. tax = (11950 * 0.10) + ((45500-11950) * 0.15) + ((117450-45500) * 0.25) + ((190200-117450) * 0.28) + ((372950-190200) * 0.33) + ((income-372950) * 0.35);
  75. }
  76. }
  77. System.out.println("Tax is " + tax);
  78. }
  79. }
  80.  
Success #stdin #stdout 0.06s 2184192KB
stdin
1
232
stdout
Which filing status number suits you? 
0. Single filer
1. Married filing jointly
2. Married filing seperately
3. Head of household

Enter the filing status: Enter the taxable income: Tax is 23.200000000000003