• February 16th, 2012, 05:15 PM
javanoobieman
i can't do these last two questions for college and i would really appreciate some help:

9. SlowDrivers Inc. pay their workers a basic wage of £4.60 an hour. If an employee works over 40
hours a week they receive £5.60 an hour for every hour of overtime they work. Workers can work a
maximum of 80 hours a week.**

Create a function called calculateWage. The function should prompt the user to enter the number
of hours they have worked and assign this to a variable called hours. Create two variables
basicWage and overTime which will store the rates of pay. Complete the rest of the code for this
function which will calculate the user’s wage based on the number of hours that they have worked
in that week.**

If a user has entered a correct number of hours, then the alert box should say “Your basic wage is
£” followed by the correct output. If the user enters an incorrect number of hours, then the alert
box should say “Please check the number of hours that you have worked.” [14]
Hint: use the built in method of .toFixed(2) to ensure the final wage is displayed to two
decimal places.
* *

10. HighPrice Gas Ltd. charge their customers for gas as follows
No of Units used Price(£)
0 to 100 £1 per unit
101 to 1000 £1 per unit, plus 50p for each additional unit over 500
Over 1000 £3 per unit, plus 5p for each additional unit over 1000
Create a function called gasReading which takes a parameter called units. When run, the function
should pass in the number of units used by a customer and calculate the price, which is stored in a
variable called cost. The function should then return the cost as part of an alert box, with the text
“Your gas bill is: ” and then display the cost of the gas used. Call this function, passing the value
1200 as a parameter. [12]

Thank you
• February 16th, 2012, 05:52 PM
snowguy13

Now, have you started any code so far? If so, could you post it please? (Be sure to use the correct syntax: [highlight=Java]//your code here[/highlight]

If you don't have code, I suggest creating on a piece of paper a model representing the structure of your program (paths of execution based on the hours worked, input validation ideas, etc.).
• February 16th, 2012, 07:57 PM
javanoobieman
for now for question 9 i have:

function calculateWage() {
var basicWage = 4.60;
var overTime = 5.60;
var hours = prompt("enter hours worked");
if (hours > 40) {
• February 16th, 2012, 08:33 PM
snowguy13
Are you doing this in Java, or another coding language? The code you have posted above does not follow Java syntax (in fact, it looks more like Flash or JavaScript)...
• February 16th, 2012, 08:40 PM
javanoobieman
yeah sorry its javascript
• February 16th, 2012, 08:45 PM
copeg