Paycheck Calculator Please use the Paycheck Calculator Drop Box to submit your a
ID: 3791510 • Letter: P
Question
Paycheck Calculator Please use the Paycheck Calculator Drop Box to submit your assignment. In this assignment you need to write a JavaScript script that will calculate and display the weekly gross pay, taxes, and net pay. The input will be the hourly wage and the weekly hours worked by the employee. The script will then calculate and display the following Gross Pay (hours X pay rate if hours less or equal to 40 otherwise see how to calculate overtime below) Federal Taxes (10.65% of Gross Pay) State Taxes (4% of Gross Pay) Social Security Taxes (3.8% of Gross Pay) Medicare (1.3% of Gross Pay) Total Taxes (Federal State SS Medicare Net Pay (Gross Pay-Total Taxes) For this assignment the weekly hours and the pay rate will be entered using the prompt function. overtime pay rate of 1.5 times the regular pay rate should be applied to hours over 40. You should use an "if else" statement to calculate the gross pay. If the hours worked are less or equal to 40 then the gross pay will be hours worked times the pay rate. Otherwise, the first 40 hours will be multiplied with the pay rate and you should add to it all hours above 40 times pay rate times 1.5 The JavaScript script should calculate and display the results in the following format. Hello John Smith This week you worked 40 hours and based on the pay rate of $10.00 per hour your pay check information is Gross Pay $400.00 Federal Taxes $42.60 State Taxes: $16.00 Social Security Taxes $15.20 Medicare Taxes $5.20 Total Taxes $79.00 Net Pay: $321.00Explanation / Answer
<html>
<head>
<title>Paycheck Calculator</title>
<script language="javascript" type="text/javascript">
//getting employee name
var name=prompt('Enter your name');
//getting number of hours worked
var weekly_hours=Number(prompt('Enter the number of hours worked'));
//getting pay rate
var pay_rate=Number(prompt('Enter the pay rate'));
//number of hours greater than 40 if block ... otherwise else block
if (weekly_hours > 40)
{
var over_time=weekly_hours-40;
var gross_pay=((weekly_hours-over_time) * pay_rate) +( over_time * pay_rate * 1.5);
}
else
{
var gross_pay=weekly_hours * pay_rate;
}
//calculating federal tax
var fed_tax=(10.65/100)* gross_pay;
//calculating state tax
var state_tax=(4/100)* gross_pay;
//calculating security tax
var security_tax=(3.8/100)* gross_pay;
//calculating medicare
var medicare=(1.3/100)* gross_pay;
//adding all taxes
var total_tax=fed_tax+state_tax+security_tax+medicare;
//subtracting all taxes from the gross pay
var net_pay=gross_pay-total_tax;
document.write("Hello "+ name + "." + " This week you worked "+weekly_hours+" hours and, based on the pay");
document.write("rate of $"+ pay_rate.toFixed(2) + " per hour, your pay check information is:<br>");
document.write("<b>Gross Pay:</b> $"+ gross_pay.toFixed(2)+"<br>");
document.write("<b>Federal Taxes:</b> $"+fed_tax.toFixed(2)+"<br>");
document.write("<b>State Taxes:</b> $"+state_tax.toFixed(2)+"<br>");
document.write("<b>Social Security Taxes:</b> $"+security_tax.toFixed(2)+"<br>");
document.write("<b>Medicare Taxes:</b> $"+medicare.toFixed(2)+"<br>");
document.write("<b>Total Taxes:</b> $"+total_tax.toFixed(2)+"<br>");
document.write("<b>Net Pay:</b> $"+net_pay.toFixed(2));
</script>
</head>
<body>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.