Last active
July 31, 2024 14:32
-
-
Save Raouf25/8189b661b5b32b32b7475d6bc3cc6537 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TaxCalculator { | |
// Method to calculate the tax based on income | |
public double calculateTax(double income) { | |
double tax; | |
if (income <= 10225) { | |
tax = 0; | |
} else if (income <= 26070) { | |
tax = (income - 10225) * 0.11; | |
} else if (income <= 74545) { | |
tax = (26070 - 10225) * 0.11 + (income - 26070) * 0.30; | |
} else if (income <= 160336) { | |
tax = (26070 - 10225) * 0.11 + (74545 - 26070) * 0.30 + (income - 74545) * 0.41; | |
} else { | |
tax = (26070 - 10225) * 0.11 + (74545 - 26070) * 0.30 + (160336 - 74545) * 0.41 + (income - 160336) * 0.45; | |
} | |
return tax; | |
} | |
// Main method to test the tax calculation | |
public static void main(String[] args) { | |
TaxCalculator calculator = new TaxCalculator(); | |
System.out.println(calculator.calculateTax(50000)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment