₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,009 members, 8,419,904 topics. Date: Thursday, 04 June 2026 at 07:04 AM

Toggle theme

Javascript Problems - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingJavascript Problems (1979 Views)

1 Reply (Go Down)

Javascript Problems by jt2010(op): 1:38pm On May 16, 2012
Hi guys,

We were given the following assignment in school and am a new biz to programming or coding.


Develop a JavaScript program that will determine the gross pay for each of the 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 employees of the company, the number of hours each employee worked last week and the hourly rate of 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.

This is what i have been able to come up with and i believe i need need help and guidance from the pros in the house on this.

<html>
<head>
<title>Hours worked for employees</title>
</head>
<body>
<h1>hours worked</h1>
<script type="text/javascript">




var name = prompt( 'Enter Name:', '');
var straightimeworked = 40;
var overtimehours = 10;

var hourlywage = '8.25';
var answer = straightimeworked + overtimehours + hourlywage;



for(var i=0; i<straightimeworked.length; i++) {
num = parseInt( prompt( 'how many of item '+(i+1),'0'));
if(!isNaN(num)) accumulator += items[i]*num;
}
{
num = parseInt( prompt( 'how many regular hours worked this week '+(i+1),'0'));
num = parseInt( prompt( 'how many overtime hours worked this week '+(i+1),'0'));
document.write('The gross pay of employee "answer" is: ' + answer + '<br />');
}
</script>
</body>
</html>
Re: Javascript Problems by delomos(m): 3:03pm On May 16, 2012
jt2010: Hi guys,

We were given the following assignment in school and am a new biz to programming or coding.


Develop a JavaScript program that will determine the gross pay for each of the 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 employees of the company, the number of hours each employee worked last week and the hourly rate of 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.

This is what i have been able to come up with and i believe i need need help and guidance from the pros in the house on this.

<html>
<head>
<title>Hours worked for employees</title>
</head>
<body>
<h1>hours worked</h1>
<script type="text/javascript">




var name = prompt( 'Enter Name:', '');
var straightimeworked = 40;
var overtimehours = 10;

var hourlywage = '8.25';
var answer = straightimeworked + overtimehours + hourlywage;



for(var i=0; i<straightimeworked.length; i++) {
num = parseInt( prompt( 'how many of item '+(i+1),'0'));
if(!isNaN(num)) accumulator += items[i]*num;
}
{
num = parseInt( prompt( 'how many regular hours worked this week '+(i+1),'0'));
num = parseInt( prompt( 'how many overtime hours worked this week '+(i+1),'0'));
document.write('The gross pay of employee "answer" is: ' + answer + '<br />');
}
</script>
</body>
</html>
^^^ Paste this code on www.jsfiddle.com (put it in the "javascript" box) and see if you can figure out what the issue is, and then we can go from there (then you can ask a specific question).
Re: Javascript Problems by jt2010(op): 4:39pm On May 16, 2012
the Website you provide for uploading is not loading, please check

But i have upload the file to this site:

https://gist.github.com/2711460

I just want your expert advise base on the question and what i have come up with.
Re: Javascript Problems by delomos(m): 6:19pm On May 16, 2012
jt2010: the Website you provide for uploading is not loading, please check

But i have upload the file to this site:

https://gist.github.com/2711460

I just want your expert advise base on the question and what i have come up with.
I've outlined how to approach the problem here: http://jsbin.com/utibuq/2/edit (read the comments)
1 Reply

Javascript With NodeJSLets Solve Some Javascript ProblemsLets Solve Some Javascript Problems234

Need This Book - Professional's Guide To POS For .NET By Sean D. LimingHow To Build A One-on-one Chat Im With Phpsockets.ioCodeigniter Tutorial For Beginners- Explanation With Text,pics And Video