Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. import java.util.Scanner;
  2. class Main {
  3. static double calculateTax(double income) {
  4. double tax = 0.0;
  5. if (income <= 50_000.00) {
  6. tax = income * .01;
  7. }
  8. else if (income >= 50_000.01 && income <= 75_000) {
  9. tax = ((income - 50_000) * .02) + (50_000 *.01);
  10. }
  11. else if (income >= 75_000.01 && income <= 100_000.00) {
  12. tax = (income - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
  13. }
  14. else if (income >= 100_000.01 && income <= 250_000) {
  15. tax = (income - 100_000) * .04 + (100_000 - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
  16. }
  17. else if (income >= 250_000.01 && income <= 500_000) {
  18. tax = (income - 250_000) * .05 + (250_000 - 100_000) * .04 + (100_000 - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
  19. }
  20. else {
  21. tax = (income - 500_000) * .06 + (500_000 - 250_000) * .05 + (250_000 - 100_000) * .04 + (100_000 - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
  22. }
  23. // Don't remove this line.
  24. return tax;
  25. }
  26.  
  27. public static void main (String [] args) {
  28. Scanner in = new Scanner(System.in);
  29. System.out.println("Enter the amount of taxable income: ");
  30. double income = in.nextDouble();
  31. double tax = calculateTax(income);
  32. System.out.printf("Amount of tax on $%12.2f is $%12.2f\n", income, tax);
  33. }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement