QuestionQuestion

You work at a nursery and keep track of the inventory of plants available. Create a class named Supplier that has instance variables of supplierId, companyName and phone. Include your two constructors, toString() method and getters and setters.

Create a class named Inventory that has instance variables of inventoryId, itemName, numInStock, priceEach, and Supplier. Include your two constructors, toString() method and getters and setters. Write a method named totalValue() that returns the number in stock times the price each.

Write a driver program named NurseryDriver that asks the user for the supplier id, the company name and the phone number. Create an instance of the Supplier class.
Write a driver program named NurseryDriver that asks the user for the supplier id, the company name and the phone number. Create an instance of the Supplier class. Then ask the user for the number of items and loop to get the details for each (see sample output below).   Create an instance of the Inventory class (let Java generate the inventory id starting at 1000). Call the toString() method of the Inventory class to print out the item. Repeat the loop.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class Inventory {

    /**
    * Create a class named Inventory that has instance variables of
    * inventoryId, itemName, numInStock, priceEach, and Supplier
    */
    private int inventoryId;
    private String itemName;
    private int numInStock;
    private double priceEach;
    private Supplier supplier;
    private static int nextNum = 1000;

    /**
    * Include your two constructors, toString() method and getters and setters.
    */
    public Inventory() {
       inventoryId = nextNum;
       itemName = "";
       numInStock = 0;
       priceEach = 0;
       supplier = null;
       nextNum++;
    }

    public Inventory(String itemName,
            int numInStock, double priceEach, Supplier supplier) {
       this.inventoryId = nextNum;
       this.itemName = itemName;
       this.numInStock = numInStock;
       this.priceEach = priceEach;
       this.supplier = supplier;
       nextNum++;
    }

    @Override
    public String toString() {
       return "Inventory Id: " + inventoryId + System.lineSeparator()
                + "Item name: " + itemName + System.lineSeparator()
                + "Num in Stock: " + numInStock + System.lineSeparator()
                + "Price each: $" + priceEach + System.lineSeparator()
                + "Total value: $" + totalValue() + System.lineSeparator()
                + supplier.toString();
    }...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$20.00 $10.00
for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats