Question

1. In a separate JS file, write a function to calculate gross wages for an hourly...

1. In a separate JS file, write a function to calculate gross wages for an hourly employee. The function should receive two parameters: the pay rate (dollars per hour, a floating point number) and the hours worked. Hours from 0 through 40 are “straight time” pay, and any hours in excess of 40 are overtime pay at 1.5 times the standard rate (hint: use the ? : operator to make a decision about pay rates). The function should return a floating point number representing the gross pay amount. Note, the function should not do any output such as document.writeln or alerts.

2. In a separate JS file, write a function to compute the amount of taxes that should be withheld from a paycheck based on the gross pay. The function should receive one parameter, the gross pay. Withholdings are calculated based on the following table:

Category

Percentage

Federal taxes

31%

State taxes

8%

Local taxes

2%

All local taxes are deductable from the gross amount used to calculate state taxes. Likewise all state and local taxes are deductable from the gross amount used to calculate federal taxes. The function should accept one parameter, the gross pay, and return one result, the total withholdings based on the above table and rules. Again, the function should not do any output, but should just return a number. Here is an example:

Input: 1000.00, return 377.90. Why not just 41% of 1000 = 410? 2% of $1000.00 is $20.00. Now subtract the $20.00 out of the gross, leaving $980.00 as the base for calculating state taxes.   8% of $980.00 is $78.40. Subtract $78.40 from the $980.00 to get $901.60, the base for calculating federal taxes. 31% of $901.60 is $279.50 (rounded to the nearest penny). When $20.00, $78.40, and $279.50 are added together, the result is $377.90, which is the answer that should be returned from the function. Note that these numbers are rounded to the nearest penny, which is possible with either the .toFixed() method of a number or by using Math.round().

Homework Answers

Answer #1

(1) JS File:

//Function that calculates gross pay
function calculateGrossWages(payrate, hoursWorked)
{
    var totalPay;
  
   //Using Ternary Operator(?=) for calculation of total pay
    totalPay = (hoursWorked > 40) ? ( (40 * payrate) + (1.5 * (hoursWorked-40) * payrate) ) : (hoursWorked * payrate);
  
   //Returning totalPay
    return totalPay;
}

Sample Run:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(2) Js File:

//Function that calculates gross pay
function computeTaxDeductable(grossPay)
{
    var holdings = 0;
  
   //Calculating local taxes
   localTax = grossPay * (2/100.0);
  
   //Updating holdings
   holdings += localTax;
  
   //Deducting local taxes
   grossPay -= localTax;
  
   //Calculating State taxes
   stateTax = grossPay * (8/100.0);
  
   //Updating holdings
   holdings += stateTax;
  
   //Deducting state taxes
   grossPay -= stateTax;
  
   //Calculating federal taxes
   federalTax = grossPay * (31/100.0);
  
   //Updating holdings
   holdings += federalTax;
  
   //Deducting local taxes
   grossPay -= federalTax;
  
   //Returning total holdings
    return holdings.toFixed(2);
}

Sample Run:

Know the answer?
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
Similar Questions
c++ Write a program that calls a function calculateSum to calculate the sum from -1 to...
c++ Write a program that calls a function calculateSum to calculate the sum from -1 to N. The function calculateSum has one parameter N of type integer and returns an integer which represents the sum from -1 to N, inclusive. Write another function calculateAverage that calculates an average. This function will have two parameters: the sum and the number of items. It returns the average (of type float). The main function should be responsible for all inputs and outputs. Your...
write C++ programs Array of Payroll Objects Design a PayRoll class that has data members for...
write C++ programs Array of Payroll Objects Design a PayRoll class that has data members for an employee’s hourly pay rate and number of hours worked. Write a program with an array of seven PayRoll objects. The program should read the number of hours each employee worked and their hourly pay rate from a file and call class functions to store this information in the appropriate objects. It should then call a class function, once for each object, to return...
In preparing for next year, on December 1 Tony Freedman hired two hourly employees to assist...
In preparing for next year, on December 1 Tony Freedman hired two hourly employees to assist with some troubleshooting and repair work. a. Prepare a payroll register for the three pay periods. b. Record the following transactions in the general journal and post them to the general ledger. Assume the following transactions: Dec. 7 Paid employee wages: Lance Kumm, 38 hours, and Anthony Hall, 42 hours. Dec. 14 Paid employee wages: Lance Kumm, 25 hours, and Anthony Hall, 36 hours....
Answer the following questions: 41.- Kathryn Holmes cumulative earnings are $45,000 and her gross pay for...
Answer the following questions: 41.- Kathryn Holmes cumulative earnings are $45,000 and her gross pay for the week is $500 if the FICA rates are Social Security 6.2% on a limit Security and FICA-Medicare taxes for the week? a) $31.00 $7.25 b) $310.00 $72.50 c) $3.10 $0.73 d) $25.50   $8.00 42.- The balance in the Salaries and Wages Payable account is equal to net pay True False 43.- The Federal Unemployment Tax is a) paid by the employer b) paid...
q 1. Liquidity refers to Select one: a. the ease of converting a financial resource into...
q 1. Liquidity refers to Select one: a. the ease of converting a financial resource into cash without a loss in value. b. the amount of insurance coverage a person has. c. a positive net cash flow to cover unexpected expenses. d. a person's inability to pay his or her debt or other obligations. Question 2 Balance sheet assets should be valued at Select one: a. insured value. b. fair market value. c. original purchase price. d. replacement value. Question...
Example 4-3 To use the wage-bracket method, follow the steps illustrated below. Step 1 Select the...
Example 4-3 To use the wage-bracket method, follow the steps illustrated below. Step 1 Select the withholding table that applies to the employee's marital status and pay period. ➡ Adrienne Huff is married and claims 3 allowances. She is paid weekly at a rate of $815. Step 2 Locate the wage bracket (the first two columns of the table) in which the employee's gross wages fall. ➡ Locate the appropriate wage bracket (see Figure 4.7): At least $810 but less...
1. Liam, an international student from Ireland, has a Form W-2 that shows amounts withheld for...
1. Liam, an international student from Ireland, has a Form W-2 that shows amounts withheld for Social Security and Medicare taxes. Laim is an F-1 nonresident alien for tax purposes. Which form should he file to receive a refund of these taxes once attempts to obtain a refund through his employer have failed? a. Form 843 b. Form 8233 c. Form 8880 d. Form 8962 2. Carlos and Sophia are from Mexico. Carlos is a scholar at a local university...
1. A company that reports segment information had average total assets of $1,558,450 and total net...
1. A company that reports segment information had average total assets of $1,558,450 and total net income of $644,700. Segment A had average total assets of $945,800 and segment operating income of $325,300. Segment B had average assets of $612,650 and segment operating income of $319,400. The segment return on assets for Segment B is:? 41.4% 52.1% 34.4% 60.7% 50.5% 2. During the first week of January, an employee works 47 hours. For this company, workers earn 150% of their...
It is August 2020. You are calculating the monthly paycheck, including employee withholding, and employer payroll...
It is August 2020. You are calculating the monthly paycheck, including employee withholding, and employer payroll related expenses for Bonnie Bigwig. Her pay through July is $110,000. Her August gross pay $20,000. Her Federal income tax withholding is at the 25% rate, her state withholding is at the 5% rate. (Ignore local income tax.) Her health insurance (all paid by the company) is $1,500 / month. She contributes $1,000 / month to the United Way. Give the journal entry to...
Paula Oates, age 37, is an unmarried custodial parent. Her household includes three dependent children: Harry...
Paula Oates, age 37, is an unmarried custodial parent. Her household includes three dependent children: Harry (age 15), Holly (age 13), and Holland (age 3). Oates divorced her husband 2 years ago and receives monthly alimony payments of $5,000, with $3,500 of this amount designated as child support. Oates works for a CPA firm. For 2019, Oates, who has adjusted gross income of $40,000 (as reported on Form 1040, line 8b), qualifies to itemize deductions and is subject to federal...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT