Question: Use the class Invoice provided in the exercises folder with this chapters examples to create an array of Invoice objects. Use the sample data shown

Use the class Invoice provided in the exercises folder with this chapter’s examples to create an array of Invoice objects. Use the sample data shown in Fig. 17.25. Class Invoice includes four instance variables—a partNumber (type String), a part-Description (type String), a quantity of the item being purchased (type int) and a pricePerItem

(type double) and corresponding get methods. Perform the following queries on the array of Invoice objects and display the results:

a) Use streams to sort the Invoice objects by partDescription, then display the results.

b) Use streams to sort the Invoice objects by pricePerItem, then display the results.

c) Use streams to map each Invoice to its partDescription and quantity, sort the results by quantity, then display the results.

d) Use streams to map each Invoice to its partDescription and the value of the Invoice

(i.e., quantity * pricePerItem). Order the results by Invoice value.

e) Modify Part

(d) to select the Invoice values in the range $200 to $500.

f) Find any one Invoice in which the partDescription contains the word "saw".

Fig. 17.25

Part number Part description 83 24 7 77 39 68 56 3 Electric sander Power saw Sledge hammer Hammer Lawn mower

Part number Part description 83 24 7 77 39 68 56 3 Electric sander Power saw Sledge hammer Hammer Lawn mower Screwdriver Jig saw Wrench Quantity 7 18 11 76 3 106 21 34 Price 57.98 99.99 21.50 11.99 79.50 6.99 11.00 7.50

Step by Step Solution

3.39 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilArrays import javautilList class Invoice private final String partNumber private final String partDescription private final int quantit... View full answer

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 Java How To Program Late Objects Questions!