I have the first half of the program running fine which gets the users hours worked and payrate and then prints the gross pay with overtime pay if there is any. But I need to print the net pay to the screen.
The second half of the program asks how many dependents the user claims and determines the tax rate from that answer. It then is supposed to deduct the taxes from the gross which would then be net pay.
Here is the code I have for the program
function myPay() {
var name = prompt("What is your name?");
var rate = parseInt(prompt("How much are you payed?"));
var hours = parseInt(prompt("How many hours do you work?"));
var depend = parseInt(prompt("How many dependents do you claim?"));
if (hours > 40 && rate < 20)
{
var overtime = rate * 1.5 * (hours - 40); //Beginning of overtime.
var regular = rate * 40;
var pay = overtime + regular;
}
else
var pay = rate * hours;
var net = pay * tax;
if (depend = 0 && pay > 1000)
{
var tax = .33;
}
else if (depend = 0 && pay <= 1000)
{
var tax = .28;
}
else if (depend >= 1 && depend <= 3 && pay > 1000)
{
var tax = .25;
}
else if (depend >= 1 && depend <= 3 && pay <= 1000)
{
var tax = .22;
}
else if (depend >= 4 && depend <= 6 && pay > 1000)
{
var tax = .22;
}
else if (depend >= 4 && depend <= 6 && pay <= 1000)
{
var tax = .15;
}
else if (depend > 6 && pay > 1000)
{
var tax = .15;
}
else if (depend > 6 && pay <= 1000)
{
var tax = .10;
}
document.write("<p> your paycheck </p>" + net);
}
I am getting a NaN in the output section when I run this in the browser. I am not sure if this could be because of the format I am using for the variable "tax".