Product listing and sorting program in Java with full source code

Product listing and sorting program in Java with full source code

(Manipulating a Stream<Invoice )
Use the class Invoice to create a List of Invoice objects.
Use the sample data shown in the Fig.
Class Invoice includes four properties

  • PartNumber (type int ),

  • PartDescription (type String ),

  • Quantity of the item being purchased (type int ) and

  • Price (type double ).


Perform the following queries on the List of Invoice objects and display the results:


  1. Use lambdas and streams to sort the Invoice objects by PartDescription , then display the results.

  2. Use lambdas and streams to sort the Invoice objects by Price , then display the results.

  3. Use lambdas and streams to map each Invoice to its PartDescription and Quantity , sort the results by Quantity , then display the results.

  4. Use lambdas and streams to map each Invoice to its PartDescription and the value of the Invoice (i.e., Quantity * Price ). Order the results by Invoice value.

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




Powered by