Write OrderPipeline. The first number is a threshold; then come orders customer product quantity unitPrice until the end of input. Using streams only (no explicit loops), print:
- the revenue (
mapToDouble(...).sum()), - how many orders are worth at least the threshold (
filter+count), - the distinct products, sorted, joined with
,, - the top 3 orders by total (
sortedwith a reversed comparator,limit,forEach), - the units sold (
map+reduce), - whether every order has at most 10 units (
allMatch).
For the input
100
Lina pen 10 2.5
Omar laptop 1 4200
Mei mouse 3 60
Lina mouse 1 60
Ana desk 2 350
the program prints
Revenue: 5165.00
Orders of at least 100.0: 3
Products: desk, laptop, mouse, pen
Top 3 orders:
Omar laptop 4200.00
Ana desk 700.00
Mei mouse 180.00
Units sold: 17
Every order has at most 10 units: true