Question
I don't want the program for this. I want to understand this program for this class. It is a java program to simulate shopping and
I don't want the program for this. I want to understand this program for this class. It is a java program to simulate shopping and inventory. LinkedList is required to be used.
On some shopping sites (e.g., amazon.com), a product can have multiple sellers. Usually, the seller list is displayed based on
the total cost (product price plus shipping cost). The inventory of the product at a seller determines whether the seller is on
the seller list.
For this assignment, assume you are managing three products: appleIPhone, hdmi2VgaAdapter, and USBdrive. For
simplicity, the product price and shipping cost are set at the beginning and do not change. To separately manage the seller
list in ascending order of total cost for each product, use a singly linked list. Ties are broken by seller names in alphabetically
order. When the inventory is zero, the corresponding node, is deleted.
Data should be used in a file.
Input: To simulate the shopping and inventory events, an input file contains events in the same directory as your program
file called HW1.java that has the main method. Initially, each product has no sellers (no inventory). Your submission takes
the input file name as a command-line argument. Each line is one of the following event:
SetProductPrice product seller price
SetShippingCost seller shippingCost minimumForFreeShipping
IncreaseInventory product seller quantity
CustomerPurchase product seller quantity
DisplaySellerList product
Shipping cost is zero if the product price is at least minimumForFreeShipping. DisplaySellerList considers the cost of one
item of the product.
Output: The program prints events to the standard output (screen). Each event is on one line and possible events are:
SetProductPrice product seller price
SetShippingCost seller shippingCost minimumForFreeShipping
IncreaseInventory product seller quantity updatedInventory
CustomerPurchase product seller quantity updatedInventory or NotEnoughInventoryError
DepletedInventoryRemoveSeller product seller
DisplaySellerList product
12345678901234567890123456789012345678901234567890 // just to show spacing
seller productPrice shippingCost totalCost // output starts
walmart 20.99 0.00 20.99
amazon 16.95 5.00 21.95
bestbuy 21.99 0.00 21.99
Assume a seller's name is at most 10 characters, use right justification for each column in the seller list. When inventory is
depleted, DepletedInventoryRemoveSeller is displayed and the corresponding node is removed.
Sample Input 1:
SetProductPrice appleIPhone amazon 499 SetProductPrice appleIPhone applestore 550 SetProductPrice appleIPhone bestbuy 515 SetProductPrice appleIPhone walmart 450 SetShippingCost amazon 10 20 SetShippingCost applestore 15 50 SetShippingCost bestbuy 5 35 SetShippingCost walmart 10 10 IncreaseInventory appleIPhone amazon 10000 10000 IncreaseInventory appleIPhone applestore 500 500 CustomerPurchase appleIPhone amazon 1 9999 CustomerPurchase appleIPhone bestbuy 2 NotEnoughInventoryError CustomerPurchase appleIPhone applestore 5 495 DisplaySellerList
Sample Output 1:
seller productPrice shippingCost totalCost walmart 450.00 0.00 450.00 amazon 499.00 0.00 499.00 bestbuy 515.00 0.00 515.00 applestore 550.00 0.00 550.00
Sample Input 2:
SetProductPrice USBdrive amazon 4.99 SetProductPrice AppleIphone applestore 1000 SetProductPrice USBdrive radioshack 5.99 SetProductPrice USBdrive bestbuy 3.99 SetProductPrice hdmi2VgaAdapter bestbuy 13.99 SetProductPrice USBdrive walmart 3.50 SetProductPrice hdmi2VgaAdapter walmart 12.50 SetShippingCost amazon 5 10 SetShippingCost applestore 15 50 SetShippingCost bestbuy 5 25 SetShippingCost walmart 10 5 SetShippingCost radioshack 10 5 IncreaseInventory USBdrive amazon 5000 5000 IncreaseInventory USBdrive bestbuy 500 500 IncreaseInventory USBdrive walmart 2500 2500 IncreaseInventory USBdrive radioshack 10 10 IncreaseInventory USBdrive amazon 5000 10000 IncreaseInventory AppleIphone applestore 100 100 IncreaseInventory hdmi2VgaAdapter bestbuy 100 100 IncreaseInventory hdmi2VgaAdapter walmart 1000 1000 DisplaySellerList USBdrive
Sample Output 2:
seller productPrice shippingCost totalCost radioshack 5.99 0.00 5.99 bestbuy 3.99 5.00 8.99 amazon 4.99 5.00 9.99 walmart 3.50 10.00 13.50
Sample Output 2 but seller list is for another item (hdmi2VgaAdapter):
Sample Output 2 but seller list is for another item (AppleIphone):
Sample output 2 but edit to seller list and item (USBdrive):
This is the edit:
CustomerPurchase USBdrive radioshack 10 0 DepletedInventoryRemoveSeller USBdrive radioshack DisplaySellerList USBdrive
so this should be the output:
seller productPrice shippingCost totalCost bestbuy 3.99 5.00 8.99 amazon 4.99 5.00 9.99 walmart 3.50 10.00 13.50
Step 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