Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- static double calculateTax(double income) {
- double tax = 0.0;
- if (income <= 50_000.00) {
- tax = income * .01;
- }
- else if (income >= 50_000.01 && income <= 75_000) {
- tax = ((income - 50_000) * .02) + (50_000 *.01);
- }
- else if (income >= 75_000.01 && income <= 100_000.00) {
- tax = (income - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
- }
- else if (income >= 100_000.01 && income <= 250_000) {
- tax = (income - 100_000) * .04 + (100_000 - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
- }
- else if (income >= 250_000.01 && income <= 500_000) {
- tax = (income - 250_000) * .05 + (250_000 - 100_000) * .04 + (100_000 - 75_000) * .03 + (75_000 - 50_000) * .02 + (50_000 *.01);
- }
- else {
- 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);
- }
- // Don't remove this line.
- return tax;
- }
- public static void main (String [] args) {
- Scanner in = new Scanner(System.in);
- System.out.println("Enter the amount of taxable income: ");
- double income = in.nextDouble();
- double tax = calculateTax(income);
- System.out.printf("Amount of tax on $%12.2f is $%12.2f\n", income, tax);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement