Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with the JAVA exercise/code. Please and thank you In this homework, you will implement a system that reads in an inventory file, prints

Please help with the JAVA exercise/code. Please and thank you

In this homework, you will implement a system that reads in an inventory file, prints the inventory to the console, and ships items.

Business Rules

There are two types of items tracked in the system: food items and household (durable) items

Food Items: Food items are perishable, and a perishable item has a limited shelf life. The item must be removed from the shelf when it expires. The expiration date is simply:

expiration date = date placed in inventory + shelf life in days

Household Items:

Household items have unlimited shelf life, so they do not have an expiration date. They do have (sometimes substantial) weight. The shipping cost is $10.00 / pound. If the item is shipped on a weekend day, the shipping cost should be increased by $20.00.

Example: a 20 pound item shipped on Saturday would have a shipping cost of $220.00.

Program Design

Input

The program will take as input a file formatted as follows:

food,banana,5

food,bread,10

household,toaster,5

household,washer,200

The first element in a line is the type of item: food or household good. If the item is a food item, the second element is the name, the third is the shelf life in days. If the item is a household good, the second element is the name and the third is the shipping weight in pounds.

You will create an input file with the data above called "input.txt". When you load the file you should not use a full path.

Program Flow

The following pseudocode shows the required flow of the program.

Begin

for each line in inventory file do

determine inventory type

based on type, create object to hold data

(FoodItem or Household Item)

populate item with appropriate data (weight, etc)

store in inventory list

end

for each item in inventory list do

print item

end

request shipping date from user

for each household item in inventory do

determine shipping cost based on shipping date

print shipping cost

end

End

Output

The output of the program for the input above would be

Item banana

-- Shelf Life: 5

-- Remove from Shelf: Fri Oct 10 19:37:29 CDT 2016

Item bread

-- Shelf Life: 10

-- Remove from Shelf: Wed Oct 15 19:37:29 CDT 2016

Item toaster

-- Weight: 5

Item washer

-- Weight: 200

Please enter a shipping date: March 16, 2016

Toaster will be shipped on March 16, 2016. Shipping cost is $70.00.

Washer will be shipped on March 16, 2016. Shipping cost is $2020.00.

NOTE: The remove from shelf dates are based on the date the program is run. They will not be the same as those shown above.

UML:

image text in transcribed

The classes have been specified for you, and are documented in the UML diagram below. nventoryltem Perishable Shippable String name get ShelfLife0 calculateShippingCost(String) double get Name0 String get ExpiredDate0 Date O toString0 String Foodltem Householdltem O shelf Life int weight stocked Date Date calculateShippingCost(St unusableDate G isWeekend(Date) oolean O getShelfLife0 int get ExpiredDate0 O tostringo String Date O toString0 String G Inventory Manager inventory Array List main(String[D void shipAllHouseholdItems (String) void o oadInventory (String) void O printlnventory0 void

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

Understand how to design effective service guarantees.

Answered: 1 week ago

Question

Know when firms should not offer service guarantees.

Answered: 1 week ago