I am working on coding for this assignment again. I know I am posting many here. I need feedback, was working for a few hours on this and so far not able to get it to work.
Here is the assignment questions
Develop a JavaScript program that will determine the gross pay for each of three employees. The company pays "straight time" for the first 40 hours worked by each employee and pays "time and a half" for all hours worked in excess of 40 hours. You are given a list of the company’s employees, the number of hours each employee worked last week, and the hourly wage paid to each employee.
Your program should input this information for each employee, determine the employee's gross pay, and output XHTML text that displays the employee's gross pay. Use prompt dialogs to input the data.
_____________
Here is the coding I have so far, but not all of it is working. What should i do I do i need to add more lines or move my variable around?
THanks
<html>
<head>
<title>employee wages</title>
<style type="text/css">
body { font-family:arial; }
</style>
<script type="text/javascript">
window.onload = function() {
var straighttime = 40;
var hourlywage = 7.25;
var overtime = [239.99, 129.75, 99.95, 350.89];
var name = prompt( 'Enter name of employee:', '');
var grosspay = 0.00; var num;
for(var i=0; i<overtime.straighttime; i++) {
num = parseInt( prompt( 'how much over time '+(i+1),'0'));
if(!isNaN(num)) grosspay + overtime*num;
}
var total = overtime * hourlywage * straighttime;
total = '$'+( Math.round( total*7.25 )/100 ).toFixed(2);
var e = document.getElementById( 'output' );
e.innerHTML += '<h3>'+name+'</h3>';
e.innerHTML += 'total Gross pay: '+total;
};
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
this is what i have
Here is the assignment questions
Develop a JavaScript program that will determine the gross pay for each of three employees. The company pays "straight time" for the first 40 hours worked by each employee and pays "time and a half" for all hours worked in excess of 40 hours. You are given a list of the company’s employees, the number of hours each employee worked last week, and the hourly wage paid to each employee.
Your program should input this information for each employee, determine the employee's gross pay, and output XHTML text that displays the employee's gross pay. Use prompt dialogs to input the data.
_____________
Here is the coding I have so far, but not all of it is working. What should i do I do i need to add more lines or move my variable around?
THanks
<html>
<head>
<title>employee wages</title>
<style type="text/css">
body { font-family:arial; }
</style>
<script type="text/javascript">
window.onload = function() {
var straighttime = 40;
var hourlywage = 7.25;
var overtime = [239.99, 129.75, 99.95, 350.89];
var name = prompt( 'Enter name of employee:', '');
var grosspay = 0.00; var num;
for(var i=0; i<overtime.straighttime; i++) {
num = parseInt( prompt( 'how much over time '+(i+1),'0'));
if(!isNaN(num)) grosspay + overtime*num;
}
var total = overtime * hourlywage * straighttime;
total = '$'+( Math.round( total*7.25 )/100 ).toFixed(2);
var e = document.getElementById( 'output' );
e.innerHTML += '<h3>'+name+'</h3>';
e.innerHTML += 'total Gross pay: '+total;
};
</script>
</head>
<body>
<div id="output"></div>
</body>
</html>
this is what i have