The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Assign2.pages
Problem:
The video store has expanded and now also sells used books and toys in addition to DVDs. Modify your Java program from assignment 1 (or the solution available on TRACS) to handle these different types of products in the inventory.
The inventory for the store will contain the following information for each product in the
inventory: SKU
title
price quantity
(stock-keeping unit, an integer, must be unique)
(may contain spaces in it)
(dollars and cents, greater than 0)
(number of copies in inventory, greater than or equal to 0)
In addition to these attributes, the following are stored for each product type:
For movies (dvds) a upc (universal product code) is stored
For books, an isbn (international standard book number) and author name are stored. For toys, the weight (in total ounces!!) is stored
The program should offer the user a menu with the following options (changes from assignment 1 are in bold):
1. Add a product to the inventory (user should enter a letter (M or B or T) to indicate the product category and then input corresponding values). Please prompt for the values as the same order as the sample output online.
For #3, display all the attributes for the product (this will differ for each category).
For #4, display only the product category (Movie, Book, or Toy), sku, price, quantity, and title for each product (attributes they have in common).
Â
The details of #5 Process a sale are given below.
The program should perform the operation selected by number and then re-display the menu. If the operation fails (i.e. invalid input or attempt to remove a product not in the inventory) your program should display an error message and return to the menu.
Your program should store the inventory in a file between executions of the program, so that when the program is run again it will start up with the same inventory contents as when it last terminated.
5. Process a sale
The products are offered for sale on Amazon, which charges a commission on each sold item, and refunds a shipping credit to the store for each sold item (the store must ship the items offline and pay their own shipping costs).
To process the sale of a certain product, the user must input the following:
sku of the product sold
quantity of items sold to the customer
shipping cost (the amount paid by the store to ship these item(s))
Your program should update the quantity attribute for that product in the inventory, if there are enough items of that product in the inventory. If not, it should issue an error message and abort the operation. Do NOT remove the product from the inventory.
The shipping credit and commission that Amazon charges for each type of item of are shown below. Note that for toys, the shipping credit depends on the weight (in pounds, rounded up) of the item. So for a toy weighing 18 ounces, the shipping credit isÂ
 $4.49 + ($0.50*2) = $5.49. (1 pound is 16 ounces, so 18 ounces rounds up to 2).
|
Product Type |
Shipping credit per item |
Commission |
|
Movie |
$2.98 |
12% of price |
|
Book |
$3.99 |
15% of price |
|
Toys |
$4.49 + $0.50 / lb |
15% of price |
To complete the process, compute and output the following four values:
Total price (the product’s price times the quantity sold)
Total shipping credit (the product’s shipping credit times the quantity sold) Total commission (the product’s commission times the quantity sold)
Profit = Total price + Total shipping credit - (Total commission + shipping cost)
Â
NOTES:
You may use an IDE (Eclipse, netbeans, etc) or just an editor and command line operations (javac, java) in unix or windows/dos to develop your program.
This assignment may be done with a partner (in groups of 2).
Use inheritance to implement the different product types. â—¦ Make a superclass called Product
â—¦ Make three subclasses: Movie, Book, and Toy
Use good design with respect to inheritance:
Â
Â
SAMPLE OUTPUT TEXT:
Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 1 Enter the product type. Enter M for movie, B for Book, or T for Toy: M Enter the SKU: 6666 Enter the title: Fargo Enter the price: 9.99 Enter the quantity: 5 Enter the UPC: 12345678 Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 1 Enter the product type. Enter M for movie, B for Book, or T for Toy: B Enter the SKU: 9999 Enter the title: Game of Thrones Enter the price: 5.99 Enter the quantity: 17 Enter the ISBN: 1112223333 Enter the author: George Martin Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 1 Enter the product type. Enter M for movie, B for Book, or T for Toy: T Enter the SKU: 8899 Enter the title: Monopoly Enter the price: 6.50 Enter the quantity: 12 Enter the weight in ounces: 34 Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 4 Movie 6666 5 $9.99 Fargo Toy 8899 12 $6.50 Monopoly Book 9999 17 $5.99 Game of Thrones Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 5 Movie 6666 5 $9.99 Fargo Book 9999 17 $5.99 Game of Thrones Toy 8899 12 $6.50 Monopoly Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 6 Enter SKU of sold items: 9999 Enter quantity of sold items: 2 Enter cost to ship sold items: 5.75 Total Price: $11.98 Total shipping Credit: $7.98 Total commission: $1.80 Profit: $12.41 Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 6 Enter SKU of sold items: 8899 Enter quantity of sold items: 3 Enter cost to ship sold items: 21.50 Total Price: $19.50 Total shipping Credit: $17.97 Total commission: $2.92 Profit: $13.05 Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 3 Enter SKU of product to find: 9999 sku=9999, quantity=15, price=$5.99, title=Game of Thrones isbn=1112223333 author=George Martin Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 3 Enter SKU of product to find: 8899 sku=8899, quantity=9, price=$6.50, title=Monopoly weight=34 Online Store Inventory Menu 1. Add product 2. Remove product 3. Find product by sku 4. Display inventory sorted by sku 5. Display inventory sorted by title 6. Process a sale 7. Quit the program Enter your choice: 7 Exit selected