Question: The following algorithm determines a weeks wages given the number of hours worked and the regular pay rate. Assume regular pay for the first 40

The following algorithm determines a weeks wages given the number of hours worked and the regular pay rate. Assume regular pay for the first 40 hours, overtime pay (1.5 * rate) for all hours over 40 up to and including 54, and double time (2 * rate) for all hours over 54.

For each option (regular time only; regular time plus overtime, regular time plus overtime plus double time) include JavaScript code which correctly computes weeksPay.

Here is the wages algorithm expressed in pseudocode:

Get hours from user

Get get rate from user

If (hours <= 40)

Set weeksPay to hours * rate

Else

If (hours <= 54)

Set weeksPay to 40*rate + (hours 40)*rate*1.5

Else

Set weeksPay to 40*rate + 14*rate*1.5 + (hours-54)*rate*2

Print weeksPay

Stop [note: there is no line of code in JavaScript corresponding to Stop]

Add JavaScript code (inside the tags) which implements this algorithm and prints on the web page wages for the week.

Illustration: (1st line of JavaScript, matching the first line of the algorithm)

Pseudocode JavaScript

Get hours from user var hours = parseFloat(prompt(How many hours did you work this week? ));

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!