Hello All,
This is my first time using javascript.. I am trying to do my first homework assignment which is basically to make a page that will calculate gross pay. when i try and run it in a browser the dialog boxes pop up and ask the user for the information but thats where it stops. Can anyone give me a little help or at least lead me in the right direction as to where im making my mistakes? I would really appreciate it!! Thanks much! Jessica Code:
<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3/org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Calculating gross pay</title>
<script type = "text/javascript">
//define variables
var name; //user name
var hourlyWage; //users hourly rate
var hoursWorked; //hours user worked
var netPay; //pay before taxes taken out
var grossPay; //pay after taxes taken out
var fedTaxes; //amount of federal taxes held
var stateTaxes; //amount of state taxes held
var fica; //amount of fica taxes held
var overtimeHours;
var regHours;
//Get users name
name = window.prompt( "Please enter your name" );
//Get users hourly wage
hourlyWage = window.prompt( "Please enter your hourly wage" );
//get users hours worked
hoursWorked = window.prompt( "Please enter amount of hours worked" );
if(hoursWorked > 40)
{
overtimeHours = hoursWorked - 40;
regHours = 40;
}
if(HoursWorked < 40)
{
OvertimeHours = 0;
regHours = HoursWorked;
}
//calculate gross pay
grossPay = regHours * HourlyWage + 1.5*(overtimeHours * HourlyWage);
//calculate taxes
fedTaxes = grossPay / .20;
stateTaxes = grossPay / .3;
fica = grossPay / .8;
//calculate net pay
netPay = grossPay - fedTaxes - stateTaxes - fica;
document.writeln(<h1> " BHC Group " + name "pay" </h1> );
document.writeln ("name" + name );
document.writeln ("gross pay = " + grossPay );
document.writeln ("federal taxes withdrew = " + fedTaxes );
document.writeln ("State taxes withdrew = " + stateTaxes );
document.writeln ("FICA withdrew = " + fica );
document.writeln ("Net pay = " + netPay );
</script>
</head>
<body>
</body>
</html>