Question

i can't believe i have yet to get this javascript question answered correctly?   One final try:...

i can't believe i have yet to get this javascript question answered correctly?  

One final try: Here goes.....

Please write a very simple Javascript HTML program. The purpose is to calculate an employees pay. I need 4 prompts.

The # of hours the employees worked

The # of hours the employee is contracted to work before they receive overtime

the hourly payrate

do they get 1.5 or 2 times their hourly rate for overtime

TEST TEST TEST the program with info for both employees who did not work their contracted hours as well as those who worked overtime.

THANK YOU!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.

Please open the code as HTML file.

CODE

<!DOCTYPE html>
<html>

<body>
<script>
   //prompt for worked hours
   var hours_worked = prompt("Please enter worked hours");
  
   //prompt for contract hours
   var contract_hours = prompt("Please enter hours contracted to work");
  
   //prompt for hourly pay rate
   var hourly_payrate = prompt("Please enter hourly pay rate");
  
   //prompt for overtime rate
   var overtime_rate = prompt("Please enter overtime rate (1.5/2)");
  
   //calculating overtime
   var extra_hours = hours_worked-contract_hours;
  
   var EmployeePay;
  
   //calculating employees pay for who worked overtime
   if(extra_hours>0)
       EmployeePay = (contract_hours*hourly_payrate)+(extra_hours*hourly_payrate*overtime_rate);
      
   //calculating employees pay for who not worked overtime
   else
       EmployeePay = (hours_worked*hourly_payrate);
      
   //printing outputs
    document.write("Worked Hours: "+hours_worked+"<br>")
   document.write("Contract Hours: "+contract_hours+"<br>")
   document.write("Hourly Pay Rate: "+hourly_payrate+"<br>")
   document.write("Overtime Rate: "+overtime_rate+"<br>")
   document.write("Employee Pay: "+EmployeePay+"<br>")
</script>
</body>

</html>

OUTPUT

Please enter worked hours 10 OK Cancel

Please enter hours contracted to work Prevent this page from creating additional dialogs OK CancelPlease enter hourly pay rate 100 Prevent this page from creating additional dialogs OK CancelPlease enter overtime rate (1.512) 1.5 「Prevent this page from creating additional dialogs 바 OK Cance

Worked Hours: 10 Contract Hours: 5 Hourly Pay Rate: 100 Overtime Rate: 1.5 Employee Pay: 1250

Please enter worked hours OK Cancel

Please enter hours contracted to work 10 Prevent this page from creating additional dialogs OK CancelPlease enter hourly pay rate LET 100 Prevent this page from creating additional dialogs OK CancelPlease enter overtime rate (1.512) Prevent this page from creating additional dialogs OK Cancel

Worked Hours: 5 Contract Hours: 10 Hourly Pay Rate: 100 Overtime Rate: 2 Employee Pay: 500

CODE SCREEN SHOT

<!DOCTYPE html> html> <body <script> //prompt for worked hours var hours worked-prompt (Please enter worked hours) //prompt36 37 38 39 40 document.write(Employee Pay: +EmployeePay+<br>) </script> </body> し</html>

Add a comment
Know the answer?
Add Answer to:
i can't believe i have yet to get this javascript question answered correctly?   One final try:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed...

    THIS IS WHAT I HAVE I NEED TO FIX IT SO: hours_worked should not be inputed separately. Get the hours as 40 40 40 40 or 40, 40, 40, 40 whichever separator suits you. How do I do this? How would you change what I have in to it getting into that kind of input. Thank you! class Employee: again = 'y' def __init__(self): self.__rate = 7.25 self.__totalhour = 0 self.__regularpay = 0 self.__overtimepay = 0 self.__totalpay = 0 self.__tax...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • I need help with my javascript project, I've started on it but I can't seem to...

    I need help with my javascript project, I've started on it but I can't seem to get ym java scripts to work with my index.html. Can someone please help me fix my code? I need the main.js & scratchpad.js to work with my index.html .Thank you Directions: Go to the following link: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics On that page, scroll down to "A 'hello world' example". Follow the step-by-step instructions to download their code and edit it in your text editor of choice....

  • C++ Programming Assignment Objectives: The objectives of Week 1 assignment is: Implement multiple selection using the...

    C++ Programming Assignment Objectives: The objectives of Week 1 assignment is: Implement multiple selection using the control statements ( i. e switch selection statement) Work with functions in C++ and to use the logical operators Assignment Purpose: To write a program that demonstrates the concepts of the control statements that we learned this week. Assignment Description: Problem Description: A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for...

  • In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an...

    In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...

  • I am really struggling with this assignment, can anyone help? It is supposed to work with...

    I am really struggling with this assignment, can anyone help? It is supposed to work with two files, one that contains this data: 5 Christine Kim # 30.00 3 1 15 Ray Allrich # 10.25 0 0 16 Adrian Bailey # 12.50 0 0 17 Juan Gonzales # 30.00 1 1 18 J. P. Morgan # 8.95 0 0 22 Cindy Burke # 15.00 1 0 and another that contains this data: 5 40.0 15 42.0 16 40.0 17 41.5...

  • i have the case study question with the answers but i need help to re-write the...

    i have the case study question with the answers but i need help to re-write the answers. please see the attached files Case Study Analysis (CSF3003) Assessment Description and Requirements CLO1: Case Study 1 Ahmad lef home to study master and PhD in Australia. He has fees for the first semester only. After he arrived to Sydney and settled down, he start looking for a part-time job to save money for the next term. Ahmad has some experience on making...

  • Denise Stubbs, the Nancy Drew of forensic accounting, sat in her office pondering yet another financial...

    Denise Stubbs, the Nancy Drew of forensic accounting, sat in her office pondering yet another financial mystery. Her client, Candace Goodwell, owns Salon Select and the building and land on which the building sits. The retiree, who spends her winters in Florida and her summers in New York, had just left Denise’s office after discussing a matter that was particularly troubling. Candace had relied on her office manager, D Maxwell, who had been with her for years, to obtain bids...

  • I need the answers of the 5 discussion questions CASE #3 Game Not Over, Not Yet...

    I need the answers of the 5 discussion questions CASE #3 Game Not Over, Not Yet Although their expertise lies in creating games, it's definitely Then, it's the discipline of understanding the customers by using serious business for the video game industry. The computer and focus groups to pinpoint desires and likes and dislikes. And it's the video game industry has struggled over the last couple of years discipline of sharing best practices and technologies through the as game makers...

  • Subject: HRM Introduction and Instructions You have recently been hired as the Director of Human Resources...

    Subject: HRM Introduction and Instructions You have recently been hired as the Director of Human Resources for Wilson Brothers Canada and have HR responsibility for all of the company’s Canadian operations. Bob and John Wilson have asked you to prepare a report for their review focusing specifically on organizational behavior within the company. Review the Wilson Brothers Case Scenario in depth and address the required topic listed below in your analysis report. Marks are allocated for thoroughness of coverage of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT