Use the class Invoice provided in the exercises folder with this chapters examples to create an array
Question:
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
Step by Step Answer:
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates