
Create a class named Order that performs order processing of a single item. The class has five instance variables (fields) : customer name, customer number, quantity ordered, unit price, and total price. Define a constructor that accept and initialize all fields except the total price field. Include set and get methods for each instance variable except the total price field. This class also needs a method to compute the total price, name it computePrice (quantity ordered * unit price) and a toString() method that returns all the instance variables values and the result of the computePrice() method. Create a subclass named ShippedOrder that overrides computePrice() by adding a shipping and handling charge of $4.00, override the toString() method to return the result of the new total price after the execution of the computePrice() method. Write a main class named UseOrder that instantiates an object of each of these classes. Prompt the user for data for the Order object, and display the results. In your main method, use a trycatch block to display a meaningful error message when the exception occurs. Here is a summary of this project: Class Order: â?? public Order(String customerName,int customerNumber,int quantityOrdered, double unitPrice) â?? double computePrice() â?? String getCustomerName() â?? int getCustomerNumber() â?? double getUnitPrice() â?? void setCustomerName(String customerName) â?? void setCustomerNumber(int customerNumber) â?? void setQuantityOrdered(int quantityOrdered) â?? void setUnitPrice(double unitPrice) â?? String toString() Class ShippedOrder â?? public ShippedOrder(String customerName, int customerNumber, int quantityOrdered, double unitPrice) â?? double computePrice() â?? String toString() This is an example on a valid output of the program: Please enter customer Name: Khalid Please enter customer Number: 001236789 Please enter quantity ordered: 20 Please enter unit price: 10 Customer Name: Khalid Customer Number: 1236789 Quantity Ordered: 20 Unit Price: 10.0 Total Price: 200.0 Your total price after shipment 204.0
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.