I'm having so much trouble with javascript. I'm supposed to make a simple paycheck program using function. I have no idea what I'm doing wrong. I also have to change the payrate
and taxrate
to a decimal format. How do you put that in code? Here's what my code looks like.
<html>
<body bgcolor="#81DAF5">
<head>
<title>Chapter 4 Assignment 1</title>
</head>
<body>
<script type="text/javascript">
var hoursworked = window.prompt("How many hours worked?", "");
var payrate = window.prompt("What is the pay rate?", "");
var taxrate = window.prompt("What is the tax rate?", "");
var netpay
parseFloat(payrate).toFixed(2);
parseFloat(taxrate).toFixed(2);
function calculatepay()
{
var grosspay= hoursworked * payrate;
var taxamount= (grosspay * taxrate) / 100;
var netpay= grosspay - taxamount;
return netpay;
}
document.write("<h1><b>Hours Worked: " +hoursworked+ "<br></h1></b>");
document.write("<h1><b>Hourly payrate: " +payrate+ "<br></h1></b>");
document.write("<h1><b>Tax rate applied: " +taxrate+ "<br></h1></b>");
document.write("<h1><b>Net Pay = " +calculatepay+ "<br></h1></b>");
</script>
</body>
</html>