Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an application to manage a fresh produce store. Define at least 4 classes that implement Produce (attached), such as Potato, Asparagus, etc. Each of

Create an application to manage a fresh produce store.

Define at least 4 classes that implement Produce (attached), such as Potato, Asparagus, etc. Each of these should represent a type of produce, with a name, a weight, and a price per pound. All but the weight should be hard-coded in the default constructor. For the weight, hard code a range of pounds for the produce, such as, for example, .5 to 1.5 for a Potato. Note that that can also be described a random number from 0 to 1.0 plus .5. In addition to the Interface methods and a constructor, each should also override the toString() method to return a string such as the following for a Potato: Idaho potato, 1.2 lbs. at $.60 per pound: $.73 Idaho potato, .7 lbs. at $.60 per pound: $.44

Also define a Driver which will print a menu of produce types, plus an option to check out, get the user's choice, prompt the user for a quantity, then add that many new instances of the chosen class of Produce to an ArrayList. When the option to check out is selected, the Produce should be printed out one at a time, followed by the total price, formatted as currency.

Produce:

public interface Produce { public double getWeight(); public double getPricePerPound(); public double getPrice(); }

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

=+ a. How does this change affect the incentives for working?

Answered: 1 week ago