Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

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

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.).

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) {

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)...

yeah sorry its javascript

javascript != java, and these are java forums. I've moved this thread to the Other Programming Languages section