Question: IN JAVA CODE ONLY. Write a class called Invoice that a hardware store might use to represent an invoice for an item sold at the

IN JAVA CODE ONLY. Write 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 four pieces of information as instance variables a part

number (type String), a part description (type String), a quantity of the item being purchased

(type int) and a price per item (type double). Your class should have a constructor that initializes

the four instance variables. Provide a set and get method for each instance variable. Provide a

method named GetInvoiceAmount that calculates the invoice amount (multiplies the quantity by

the price per item and then returns the amount as a double value). Provide some error checking

in this class. In the constructor and in the set method, if the quantity passed in is not positive, it

should be set to zero. In the constructor and in the set method, if the price passed in is not

positive, it should be set to zero. Provide the UML diagram for the Invoice class. Write a test

driver that demonstrates all the capabilities (methods) of this Invoice class. To do this: Create an

array of four (4) Invoice objects. Create the objects first with the parametrized constructor then

add them to the array (store a reference to each object in the array). Loop through the array of

Invoice objects and print out the current value of each objects instance variables and its Invoice

amount. Loop through the array of Invoice objects again and reset (change) each objects price

and quantity. Finally, Loop through the array of Invoice objects one last time and print out the

current value of each objects instance variables and its Invoice amount.

Then, label your output.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!