Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with this in Eclipse Java Assignment 6 Classes and Object- Inventory Item as Object In this assignment the idea is to use an
Need help with this in Eclipse Java
Assignment 6 Classes and Object- Inventory Item as Object In this assignment the idea is to use an Item class to capture what you need for recording and displaying the details of an order from an online store like Amazon This is a Class and Object assignment. Due: 03/03/19 For the assignment you must define and implement the Item class so that the code shown immediately below can produce the result shown below that. You will need to define the four private variables of the Item class for the price (a double), weightlnOunces (an int), description (a String), and quantity (an int) Have a default constructor which sets the values to 0 price, 0 weight, "Sample Item" as description and quantity 1 You are to include a second constructor, that takes three input parameters for the price, weightlnOunces, and description, but not quantity which should be set to a default value of 1 You will also need to create the remaining methods that are used in the code below the gets and sets. The contents of the main function and the output are shown below. Copy, and do not change, the code below. Pay close attention to the values in the output. If you do not match the details correctly, some of your values will not be the same as those shown. (Hint: There's a reason that the getOrderPrice() method is not called getPrice() and in the example it affects the order for glasses.) Name your main class youOrderReceipt, e.g. AjoyOrderReceipt. Turn in your zipped package folder with both java source files. Having correct formatting will now be part of the grade Part B: Create a second main class youOrderReceiptArray e.g. AjoyOrderReceiptArray Using an array of item objects, instead of item1, item2, etc. Put item1 item2 item3 and item4 in the aray. For each item in the array call showl) and Use the array and the for loop to find the dTotalPrice and iTotalWeight as in part A public static void main(Stringl] args) ( double dTotalPrice 0.0; int iTotalweight ; // Put the 4 items being ordered in iteml through item 4 Item item1 new Item(24.99, 14, "wireless Mouse"); Item item2 new Item(22.49, 27, "USB Keyboard"); Item item3 = new Item( 24.99, 12, "HDMI Cable"); Item item4 new Item(7.99, 7, "Reading Glasses"); item4.setQuantity (2); // Show the details of the order using show() System.out.println("Here are your shopping cart contents."; item1.show(); item2.show); item3.show); item4. show(); // Compute the total price and total weight in this section dTotalprice += item!.getorderPrice(); dTotalPrice += item2.getorderprice(); dTotalprice +: tem 3.getorderprice(); dTotalPrice item4.getorderPrice); TotalWeight + item!.getorderweight!nounces(); iTotalWeight += 1ten2 . getorderweightInounces ( ); Tot al Weight += item3.getorderweight Inounces ( ) ; TotalWeight +-item4 . getorderweight!nounces(); // Here we show the order details System.out.printin( The price of your order is $" + dTotalPrice); iTotaMeight / 16 + " pounds .. + iTotalleight % ounces"); System.out.println("The shipping weight is "+ 16 + The method show() should print out as shown below $24.99 each for 1 Wireless Mouse. $22.49 each for 1 USB Keyboard. $24.99 each for 1 HDMI Cable. $7.99 each for 2 Reading GlassesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started