goldy300
New Member
- Messages
- 33
- Reaction score
- 0
- Points
- 0
Not sure what I've done wrong here.
Here's whats required:
1.[FONT="] [/FONT]TAX (selection structure)
Create a web application which will determine your tax for the 2006-2007 financial year.
The tax rates and medicare levy are shown below.
Allow the user to enter their WEEKLY salary and display their annual salary, annual tax, medicare levy and total tax amounts. Ensure all currency amounts are displayed in the correct format ($ sign with two decimal places).
Save your program as tax.htm
Here's what I've done.
Here's whats required:
1.[FONT="] [/FONT]TAX (selection structure)
Create a web application which will determine your tax for the 2006-2007 financial year.
The tax rates and medicare levy are shown below.
Allow the user to enter their WEEKLY salary and display their annual salary, annual tax, medicare levy and total tax amounts. Ensure all currency amounts are displayed in the correct format ($ sign with two decimal places).
Save your program as tax.htm
RANGE($)
RATE(%)
0-6,000
0
6,001-25,000
15
25,001-75,000
30
75,001-150,000
40
More than 150,000
45
Medicare levy
1.5
Here's what I've done.
HTML:
<script language="javascript">
function calc_tax(){
var tax;
var income = parseFloat(document.taxform.income.value);
var sal = income * 52;
var taxpaid = sal * tax;
var medicare = sal * 0.015;
if(sal <= 6,000){
tax = 0;
}
else if(sal >= 6001 && sal <= 25000){
tax = 0.15;
}
else if(sal >= 25001 && sal <= 75000){
tax = 0.30;
}
else if(sal >= 75001 && sal <= 150000){
tax = 0.40;
}
else if(sal >= 150000){
tax = 0.45;
}
document.getElementById("tax").innerHTML = "<center><h3>Tax Information</h3></center>";
document.getElementById("tax").innerHTML = "Your annual salary is $" + sal.toFixed(2) + "<p>";
document.getElementById("tax").innerHTML = "The amount of tax you pay is $" + taxpaid.toFixed(2) + "<p>";
document.getElementById("tax").innerHTML = "Your medicare levy is $" + medicare.toFixed(2) + "<p>";
document.getElementById("tax").innerHTML = "Your total payments are $" + (taxpaid + medicare).toFixed(2) + "<p>";
}
</script>