subject

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.

Assume that the classes listed in the Java Quick Reference have been imported where appropriate.

Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.

In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.

Employees at a store are paid daily wages according to the following rules.

Each employee is paid the same fixed amount per day.

Each employee is paid an additional amount for each item they sold on that day.

Daily Bonus:

If the number of items sold that day by an employee is greater than a computed threshold, then the employee also receives a bonus equal to

10

percent of the employee’s daily wages.

You will write two methods in the Payroll class below.

public class Payroll

{

private int[] itemsSold; // number of items sold by each employee

private double[] wages; // wages to be computed in part (b)

/** Returns the bonus threshold as described in part (a).

*/

public double computeBonusThreshold()

{

/* To be implemented in part (a) */

}

/** Computes employee wages as described in part (b)

* and stores them in wages.

* The parameter fixedWage represents the fixed amount each employee

* is paid per day.

* The parameter perItemWage represents the amount each employee

* is paid per item sold.

*/

public void computeWages(double fixedWage, double perItemWage)

{

/* To be implemented in part (b) */

}

// Other instance variables, constructors, and methods not shown.

}

The bonus threshold is calculated based on the number of items sold by all employees on a given day. The employee with the greatest number of sales and the employee with the least number of sales on that day are ignored in the calculation. The average number of items sold by the remaining employees on that day is computed, and this value is used as the bonus threshold.

For a given day, the number of items sold by each employee is stored in the array itemsSold. The example below shows the contents of itemsSold for a day in which there were ten employees. Each array index represents an individual employee. For example, itemsSold[3] represents the number of items sold by employee 3.
(REFER TO TABLE 1)
Based on the information in the table, the bonus threshold is calculated as follows.
(48+50+37+62+38+70+55+37+64+60)−37− 70
8
=51.75
(a) Complete the method computeBonusThreshold below, which is intended to return the bonus threshold based on the contents of the itemsSold array. Assume that itemsSold has been filled appropriately and that the array contains at least three employees.
/** Returns the bonus threshold as described in part (a).
*/
public double computeBonusThreshold()
The computeWages method is intended to calculate the wages for each employee and to assign them to the appropriate element of the array wages. For example, wages[3] should be assigned the wages for employee 3. An employee’s wages consist of their daily wages plus a possible bonus and are calculated as follows.
Each employee’s wages are equal to the fixed wage plus the number of items sold times the amount paid per item sold.
If the employee sold more items than the bonus threshold, the employee also receives a 10 percent bonus added to their wages.
As described in part (a), computeBonusThreshold() returns 51.75 for the example array below.
(REFER TO TABLE 2)
Suppose that fixedWage is 10.0 and perItemWage is 1.5.
Employee 0 did not sell more items than the bonus threshold, so employee 0’s wages are equal to 10.0 + 1.5 * 48, which evaluates to 82.0. This value will be assigned to wages[0].

Employee 9 sold more items than the bonus threshold, so employee 9 receives a 10 percent bonus. Employee 9’s wages are equal to (10.0 + 1.5 * 60) * 1.1, or 110.0. This value will be assigned to wages[9].

(b) Write the method computeWages. Assume that itemsSold has been filled appropriately, and there are at least three employees in the array. Assume also that the wages array and the itemsSold array have the same length. Your solution must call computeBonusThreshold appropriately to receive full credit.
/** Computes employee wages as described in part (b)
* and stores them in wages.
* The parameter fixedWage represents the fixed amount each employee
* is paid per day.

* The parameter perItemWage represents the amount each employee

* is paid per item sold.

*/

public void computeWages(double fixedWage, double perItemWage)


SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classe
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classe

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:10, AdoNice
How can i delete permalinks from a word press site?
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, emojigirl2824
Word vocabulary words: print, proofread, status line, graphics, font effects, left margin, justification, line spacing, copy/paste, data. review words: font point, bold, save, center, error. fill in the correct word for the definition and then transfer the letters to the appropriate spot by number. some numbers will be found multiple times. you will end up with a quotation about…… what else? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 k 16 17 18 19 20 21 22 23 24 25 8 27 28 29 w 31 32 k 34 35 36 w h 39 40 41 42 8 44 45 46 47 48 49 50 51 52 53 54 55 .1. a software function that records keystrokes on a disk or drive so information can be 5 4 52 9 later retrieved. p n 2. to produce a paper copy of information. 10 7 12u n 3. a display that shows the location of the cursor, pages, etc. 45 46 18 27 36 20 42p4. pictures or images, located in clip art or other files. 6 24 44 28 34 49 555. any mis-stroke of a key. 47 41 48 2 10 n6. allows major changes to the font such as shadow, emboss, etc. 21 25 46 35 23 21 29 14 22 17 n7. a feature that centers lines of text horizontally. 49 53 46 9 51 p8. size of the font 31 16 22 b l 9. a feature that prints designated text darker than the rest to add emphasis. 32 3 . p10. to compare copy on a display screen or printout to the original 24 39 25 23 54 9 50 3 and correct errors. j un 11. a feature that allows text to be aligned at the left 11 12 7 21 16 49 40 46 34 2 and right margins. leftn 12. amount of blank space on the left side of the paper. 8 18 41 6 34 linen 13. number of blank lines between lines of text. 17 4 49 13 1914. any information inputted into the computer. 3 4 46 44 p /p15. feature that duplicates text from one location and places it in another.
Answers: 2
image
Computers and Technology, 23.06.2019 03:30, natalie2sheffield
Hashtags serve to identify the topic of a given tweet true false
Answers: 2
image
Computers and Technology, 23.06.2019 09:10, djs1671
(328 inc. 448 ind. 480 in25. john has a collection of toy cars. he has 2 red cars, 4 blue cars, 4 black cars, and 6 yellowcars. what is the ratio of red cars to yellow cars? a. 1: 2b. 1: 3c. 1: 626. the net of a right triangular prism is shown below.
Answers: 2
You know the right answer?
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.

Assume tha...

Questions in other subjects:

Konu
History, 20.10.2020 03:01
Konu
English, 20.10.2020 03:01
Konu
Mathematics, 20.10.2020 03:01