Question
JAVA HELP The application name is ProccessInvoices Invoice Class: public class Invoice { private final int partNumber; private final String partDescription; private int quantity; private
JAVA HELP
The application name is ProccessInvoices
Invoice Class:
public class Invoice { private final int partNumber; private final String partDescription; private int quantity; private double price;
// constructor public Invoice(int partNumber, String partDescription, int quantity, double price) { if (quantity = 0");
if (price = 0");
this.partNumber = partNumber; this.partDescription = partDescription; this.quantity = quantity; this.price = price; } // end constructor
// get part number public int getPartNumber() { return partNumber; // should validate }
// get description public String getPartDescription() { return partDescription; }
// set quantity public void setQuantity(int quantity) { if (quantity = 0");
this.quantity = quantity; }
// get quantity public int getQuantity() { return quantity; }
// set price per item public void setPrice(double price) { if (price = 0");
this.price = price; }
// get price per item public double getPrice() { return price; }
// return String representation of Invoice object @Override public String toString() { return String.format( "Part #: %-2d Description: %-15s Quantity: %-4d Price: $%,6.2f", getPartNumber(), getPartDescription(), getQuantity(), getPrice()); } } // end class Invoice
Use the class Invoice attached to this assignment to create an array of Invoice objects. Use the sample data shown in Table 1 to create the Invoice objects. Table 1- Data for Invoice Objects Price 57.98 99.99 21.50 11.99 79.50 6.99 11.00 7.50 Part Number 83 24 Part Description Electric sander Power saw Sledge hammer Hammer Lawn mower Screwdriver Jig saw Wrench Quantity 18 76 39 68 56 3 106 21 34 Class Invoice includes four properties - a PartNumber (type int), a PartDescription (type String), a Quantity of the item being purchased (type int), and a Price (type double). Perform the following queries on the array of Invoice objects and display the results a) b) c) Use lambdas and streams to sort the Invoice objects by PartDescription, then display the results. Use lambdas and streams to sort the Invoice objects by Price, then display the results. Use lambdas and streams to map each Invoice to its PartDescription and Quantity, sort the results by Quantity, then display the results Use lambdas and streams to map each Invoice to its PartDescription and the value of the Invoice (Quantity *Price), sort the results by Invoice value, then display the results. Modify part (d) to select only the Invoice values in the range $200 to $500 d) e)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started