java code

1) Create a Java Project called PurchaseProject, create a package called
purchaseProject, create an object class called Purchase – include these features in
the class:
a) Decide what fields are needed to describe a purchase at a retail store(for
simplicity assume the purchase is of one
item type but could be multiples of that
item – for example 6 apples or 5 oranges) at the minimum you should have a
price, quantity and item name.
b) Create a constructor with no parameters but including default values
** Note : input for item being purchased, how
many and the price will be input by
the user in the console in the driver class(using Scanner class).
c) Create methods to retrieve and modify each of the fields for the Purchase class.
** Note – in the set methods for
quantity and price – do not allow zero – if user
enters zero give them an error message and exit the project
(To exit the
project use : (System.exit(0)) the 0 means there is no error)
d) Create method to get (calculate) the order total including 8.75% tax. (use a
constant)
2) Create a driver class called PurchaseTester
a) Create an instance of the Purchase class
b) Prompt the user to enter name of the item they are purchasing, the price of the
item and the quantity of the item.
c) Accept the input and store it in a variable
d) Use this variable as input to the methods to set the Class variables.
e) Display the total cost of the transaction including the sales tax – round the result to 0 decimals using the Math.round function.

Last Completed Projects

topic title academic level Writer delivered