Question: Create an a3.html and an a3.js file. Link the two files. For each part of the assignment, add a new section to the HTML page
Create an a3.html and an a3.js file. Link the two files. For each part of the assignment,
add a new section to the HTML page with a heading, a paragraph for output, and a
button that triggers the action. Dont forget to give each paragraph an id.
a) Write the JavaScript to read the number of hours worked in the last week from the
user. Then ask for their hourly pay. Use these values to calculate how much money
the user earned. Any hours worked above 40 earn 1.5x the regular pay. So, if they
were paid $12/hour for the first 40 hours worked they would be paid $18/hr for all
hours worked over 40. Then display the hours work and amount of pay on the
webpage.
To do this create two functions. One event handler (called by the
button click) with no parameters and no return value that does the
prompt from the user and displays the output.
A second that does the calculation
Parameters: Two numbers, the hours worked and hourly wage
Operation: Calculate the total pay based on the parameters. You
can assume that the parameters have already been validated. Dont
check for NaN or negative values in the function
Returns: the calculated value
b)
Sample Output:
If the user enters 12 hours and $12/hour, the browser should show
In 12 hours you made $144
If the user enters 60 hours and $12/hour, the browser should show
In 60 hours you made $840
Display an error message (on the output paragraph) if the user did not enter a
number or entered a negative number for either value.
c) Create a button and function to ask the user three yes/no questions about their
favorite character. Then guess who the favorite character is. You can use the
yesNo function from the lab.
The three questions are
Is your favorite character small?
Is your favorite character green?
Does your favorite character use poor grammar?
Based on their answers, guess who their favorite character is using the
diagram below. If they answer no to all the questions tell the user that their
favorite character must be boring and isnt worth guessing
Create an a3.html and an a3.js file. Link the two files. For each part of the assignment,
add a new section to the HTML page with a heading, a paragraph for output, and a
button that triggers the action. Dont forget to give each paragraph an id.
a) Write the JavaScript to read the number of hours worked in the last week from the
user. Then ask for their hourly pay. Use these values to calculate how much money
the user earned. Any hours worked above 40 earn 1.5x the regular pay. So, if they
were paid $12/hour for the first 40 hours worked they would be paid $18/hr for all
hours worked over 40. Then display the hours work and amount of pay on the
webpage.
To do this create two functions. One event handler (called by the
button click) with no parameters and no return value that does the
prompt from the user and displays the output.
A second that does the calculation
Parameters: Two numbers, the hours worked and hourly wage
Operation: Calculate the total pay based on the parameters. You
can assume that the parameters have already been validated. Dont
check for NaN or negative values in the function
Returns: the calculated value
b)
Sample Output:
If the user enters 12 hours and $12/hour, the browser should show
In 12 hours you made $144
If the user enters 60 hours and $12/hour, the browser should show
In 60 hours you made $840
Display an error message (on the output paragraph) if the user did not enter a
number or entered a negative number for either value.
c) Create a button and function to ask the user three yes/no questions about their
favorite character. Then guess who the favorite character is. You can use the
yesNo function from the lab.
The three questions are
Is your favorite character small?
Is your favorite character green?
Does your favorite character use poor grammar?
Based on their answers, guess who their favorite character is using the
diagram below. If they answer no to all the questions tell the user that their
favorite character must be boring and isnt worth guessing
Create an a3.html and an a3.js file. Link the two files. For each part of the assignment,
add a new section to the HTML page with a heading, a paragraph for output, and a
button that triggers the action. Dont forget to give each paragraph an id.
a) Write the JavaScript to read the number of hours worked in the last week from the
user. Then ask for their hourly pay. Use these values to calculate how much money
the user earned. Any hours worked above 40 earn 1.5x the regular pay. So, if they
were paid $12/hour for the first 40 hours worked they would be paid $18/hr for all
hours worked over 40. Then display the hours work and amount of pay on the
webpage.
To do this create two functions. One event handler (called by the
button click) with no parameters and no return value that does the
prompt from the user and displays the output.
A second that does the calculation
Parameters: Two numbers, the hours worked and hourly wage
Operation: Calculate the total pay based on the parameters. You
can assume that the parameters have already been validated. Dont
check for NaN or negative values in the function
Returns: the calculated value
b)
Sample Output:
If the user enters 12 hours and $12/hour, the browser should show
In 12 hours you made $144
If the user enters 60 hours and $12/hour, the browser should show
In 60 hours you made $840
Display an error message (on the output paragraph) if the user did not enter a
number or entered a negative number for either value.
c) Create a button and function to ask the user three yes/no questions about their
favorite character. Then guess who the favorite character is. You can use the
yesNo function from the lab.
The three questions are
Is your favorite character small?
Is your favorite character green?
Does your favorite character use poor grammar?
Based on their answers, guess who their favorite character is using the
diagram below. If they answer no to all the questions tell the user that their
favorite character must be boring and isnt worth guessing
Create an a3.html and an a3.js file. Link the two files. For each part of the assignment,
add a new section to the HTML page with a heading, a paragraph for output, and a
button that triggers the action. Dont forget to give each paragraph an id.
a) Write the JavaScript to read the number of hours worked in the last week from the
user. Then ask for their hourly pay. Use these values to calculate how much money
the user earned. Any hours worked above 40 earn 1.5x the regular pay. So, if they
were paid $12/hour for the first 40 hours worked they would be paid $18/hr for all
hours worked over 40. Then display the hours work and amount of pay on the
webpage.
To do this create two functions. One event handler (called by the
button click) with no parameters and no return value that does the
prompt from the user and displays the output.
A second that does the calculation
Parameters: Two numbers, the hours worked and hourly wage
Operation: Calculate the total pay based on the parameters. You
can assume that the parameters have already been validated. Dont
check for NaN or negative values in the function
Returns: the calculated value
b)
Sample Output:
If the user enters 12 hours and $12/hour, the browser should show
In 12 hours you made $144
If the user enters 60 hours and $12/hour, the browser should show
In 60 hours you made $840
Display an error message (on the output paragraph) if the user did not enter a
number or entered a negative number for either value.
c) Create a button and function to ask the user three yes/no questions about their
favorite character. Then guess who the favorite character is. You can use the
yesNo function from the lab.
The three questions are
Is your favorite character small?
Is your favorite character green?
Does your favorite character use poor grammar?
Based on their answers, guess who their favorite character is using the
diagram below. If they answer no to all the questions tell the user that their
favorite character must be boring and isnt worth guessing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
