As a newcomer to JavaScript, I am trying my hand at creating an online tax calculator for our website. While I can understand pre-written calculations, developing my own has proven to be challenging. The objective is simple: the user inputs their Gross Income and clicks "Calculate" to see Tax Payable, Medicare Levy, and Net Income (Gross-Tax-Medicare).
Currently, I have found some foundational code for tax calculations, but I need to tweak it for accuracy. The issue lies in correctly applying the Medicare value as there are actually three different levels based on income brackets.
I'm struggling with merging these calculations and subtracting them from Gross Income to get the Net Result. Before diving into the final calculation, I want to figure out how to integrate multiple functions in one script.
Building this calculator step by step seems like the best approach, yet I hit a roadblock right away. For testing purposes, you can view the progress at .
Any assistance would be greatly appreciated as I await guidance from a JavaScript tutorial to deepen my understanding of the language.
The new Medicare calculation I'm looking to incorporate is outlined below:
// Updated Medicare Calculation:
if (income > 0 && income <= 19404) {
medicare = (income * 0) / 100;
}
else if (income > 19404 && income <= 22828) {
medicare = (income * 10) / 100;
}
else if (income > 22828) {
medicare = (income * 1.5) / 100;
}