Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,387 members, 7,819,396 topics. Date: Monday, 06 May 2024 at 03:34 PM

Javascript Problems - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Javascript Problems (1854 Views)

Javascript With NodeJS / Lets Solve Some Javascript Problems / Lets Solve Some Javascript Problems (2) (3) (4)

(1) (Reply) (Go Down)

Javascript Problems by jt2010: 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: 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)

How To Shut Down Or Restart The Computer With A Batch File / Need help with 2-way SMS In Nigeria / Let’s Talk Data Science, Analytics, Machine Learning, Big Data And AI

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.