Question: In Java pls Q2: Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the
In Java pls
Q2: Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include two data membersa part name (type string), and the part price (type int). Your class should have a constructor that initializes the two data members. In addition, write a highestPrice method, which receives a variable number of arguments of type Invoice. The method returns a reference to the invoice that has the highest price. Write a test program that demonstrates class Invoice's capabilities. Provide a main() method that creates three Invoice objects and call the method highestPrice twice, first passing two objects of class Invoice and second passing three objects of class Invoice. After each call, print the invoice with the highest price. (4 marks) Q3: 1- Write a one-line statement that implements a method called getMidval that returns the middle value of the three integers given as input. Do not use if statements or loops
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
