Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the Java program Requirements: Create a project named as SU15LAB3_LastName

ID: 665670 • Letter: W

Question

Write the Java program

Requirements:

Create a project named as SU15LAB3_LastName_PART2 then add the source file named SU15LAB3_LastName_WholeSaleStore.java that helps the users to calculate charge and print out the receipt when their customer order the items.

The program will do the following tasks:

ask users to provide the customer ID, Item ID, Unit price, number of items ordered and percentage discount. The program read these information from the keyboard

Create a Order object with the above information

Print out the receipt as the following format:

Customer ID:          C218

Item ID:                   1122334455

Number of items:   15

Price of Unit:            $452.99

Base charge:            $6794.85

Discount (10%):       $697.49

Subtotal:                  $6115.37

Sale tax (8.5%):       $519.81

Total Amount:         $6635.17

Where C218, 1122334455, 15, 452.99, 10% are provided from users for customer ID, item ID, unit price, number of items ordered and percentage discounted

Instruction How to do:

To do this lab part2 you need two classes: OrderInvoice_LastName and SU15LAB3_LastName_WholeSaleStore

Class OrderInvoice_LastName (this is data type class)

-Fields or data member list:

* customerID: is a String

* ItemID: is a String

* numberItems: is an int

* unitPrice: is a double

* percentageDiscount: is a double (for example 4.5 for 4.5%)

-Constructor:

* no argument constructor

* parameter constructor (Learn how to write the constructor at Learn From Questions page)

-Methods

* mutator methods and accessor methods (see examples on slide 3.18 and 3.19 or learn how to write at Learn From Questions page)

* method to calculate the base charge

   Base charge = unit price * number of items

* method to calculate the discount amount

   Discount = base charge * percentageDiscount / 100

* method to calculate the subtotal

    Subtotal = base charge – discount

* method to calculate the tax

    Sale tax = subtotal * 8.5%

* method to calculate the total amount

   Total amount = subtotal + sale tax

* method toString (learn how to write the method toString at Learn from Questions page)

Class SU15LAB3_LastName_WholeSaleStore (this is the controlling class or driver class)

-Read input: Display message to ask users to provide information and read them from the keyboard: the customer ID, Item ID, Unit price, number of items ordered and percentage (use the Scanner object to read)

-declare an object of OrderInvoice_Lastname by using parameter constructor

-Display the result by using the OrderInvoice_Lastname object declared above to call the method toString

Explanation / Answer

OrderInvoice_LastName class:- class OrderInvoice_LastName{ private String customerID; private String itemID; private int numberItems; private double unitPrice; private double percentageDiscount; public OrderInvoice_LastName(){ customerID=""; itemID=""; numberItems=0; unitPrice=0.0; percentageDiscount=0.0; } public OrderInvoice_LastName(String customerID,String itemID,int numberItems,double unitPrice,double percentageDiscount){ this.customerID=customerID; this.itemID=itemID; this.numberItems=numberItems; this.unitPrice=unitPrice; this.percentageDiscount=percentageDiscount; } public String getCustomerID() { return customerID; } public void setCustomerID(String customerID) { this.customerID = customerID; } public String getItemID() { return itemID; } public void setItemID(String itemID) { this.itemID = itemID; } public int getNumberItems() { return numberItems; } public void setNumberItems(int numberItems) { this.numberItems = numberItems; } public double getUnitPrice() { return unitPrice; } public void setUnitPrice(double unitPrice) { this.unitPrice = unitPrice; } public double getPercentageDiscount() { return percentageDiscount; } public void setPercentageDiscount(double percentageDiscount) { this.percentageDiscount = percentageDiscount; } public double baseCharge(){ return unitPrice*numberItems; } public double discountAmount(){ return (baseCharge()*percentageDiscount)/100; } public double subTotal(){ return baseCharge()-discountAmount(); } public double tax(){ return (8.5*subTotal())/100; } public double totalAmount(){ return subTotal()+tax(); } public String toString(){ String str=" Customer ID: "+customerID; str+=" Item ID: "+itemID; str+=" No. of items: "+numberItems; str+=" Price of Unit: "+unitPrice; str+=" Discount ("+percentageDiscount+"%): "+discountAmount(); str+=" Subtotal: "+subTotal(); str+=" Sale tax (8.5%): "+tax(); str+=" Total Amount: "+totalAmount(); return str; } } SU15LAB3_LastName_WholeSaleStore class:- import java.util.Scanner; public class SU15LAB3_LastName_WholeSaleStore { public static void main(String[] args) { String customerID, itemID; int numberItems; double unitPrice; double percentageDiscount; Scanner s = new Scanner(System.in); System.out.println("Enter customer ID: "); customerID=s.next(); System.out.println("Enter item ID: "); itemID=s.next(); System.out.println("Enter number of items: "); numberItems = s.nextInt(); System.out.println("Enter unit price: "); unitPrice=s.nextDouble(); System.out.println("Enter percentage discount: "); percentageDiscount=s.nextDouble(); OrderInvoice_LastName o=new OrderInvoice_LastName(customerID,itemID,numberItems,unitPrice,percentageDiscount); System.out.println(o.toString()); } }