Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java ( netbeans ) Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the

java ( netbeans )
image text in transcribed
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 four pieces of information as instance variables- 1- a part number (type String), 2- a part description (type String), 3- a quantity of the item being purchased (type int) and 4- a price per item (double). - Your class should have this operator that initializes the four instance variables. Provide a set and a get method for each instance variable. - In addition, provide a method named getInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a double value. If the quantity is not positive, it should be set to 0 . If the price per item is not positive, it should be set to 0.0. Write a test application named InvoiceTest that demonstrates class Invoice's capabilities. Hints: - The input values for the quantity and the price per item must be validated before they can be used to set the corresponding instance variables. This should be done both in the constructor and in the appropriate set methods. - The method header for getInvoiceAmount should be public double getinvoiceAmount0. Your output should appear as follows

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions