Write a JavaScript script that will calculate and display the weekly gross pay,
ID: 3790570 • Letter: W
Question
Write a JavaScript script that will calculate and display the weekly gross pay, taxes, and net pay.
This has to be done in Javascript.
Details are below:
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>Registration Form</title>
<script type = "text/javascript">
function calc()
{
var bp,DA,HRA,GP,PF,Tax,Deduction,NetPay,name,id,desg;
name = document.form1.firstname.value;
id = document.form1.userid.value;
desg = document.form1.designation.value;
bp = parseInt(document.form1.bp.value);
DA = bp * 0.5;
HRA = bp * 0.5;
GP = bp + DA + HRA;
PF = GP * 0.02;
Tax = GP * 0.01;
Deduction = Tax + PF;
NetPay = GP - Deduction;
document.form1.da.value = DA;
document.form1.hra.value = HRA;
document.form1.gp.value = GP;
document.form1.pf.value = PF;
document.form1.tax.value = Tax;
document.form1.deduction.value = Deduction;
document.form1.netpay.value = NetPay
}
</script>
</head>
<body >
<form name = "form1">
<table border = "1">
<tr>
<td>Name</td>
<td><input type = "text" name = "firstname" /></td>
</tr>
<tr>
<td>User ID</td>
<td><input type = "text" name = "userid" /></td>
</tr>
<tr>
<td>Designation</td>
<td><input type = "text" name = "designation" /></td>
</tr>
<tr>
<td>Basic Pay</td>
<td><input type = "text" name = "bp"></td>
</tr>
<tr>
<td colspan = "2" align = "center">
<input type = "button" name = "calculate" value = "Click Here To Calculate"onclick ="calc()"></td>
</tr>
<tr>
<td>Dearness Allowance </td>
<td><input type = "text" name = "da"/></td>
</tr>
<tr>
<td>House Rent Allowance </td>
<td><input type = "text" name = "hra"></td>
</tr>
<tr>
<td>GP</td>
<td><input type = "text" name = "gp"></td>
</tr>
<tr>
<td>Provident Fund</td>
<td><input type = "text" name = "pf" /></td>
</tr>
<tr>
<td>Tax</td>
<td><input type = "text" name = "tax" /></td>
</tr>
<tr>
<td>Deduction</td>
<td><input type = "text" name = "deduction" /></td>
</tr>
<tr>
<td>NetPay</td>
<td><input type = "text" name = "netpay" /></td>
</tr>
</table>
</form>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.