I have been struggling with this program. It's an inventory program for class. It won't run and I need to modify it today with the following criteria Please help:
Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.
· Create a method to calculate the value of the entire inventory.
· Create another method to sort the array items by the name of the product.
My Code:
package inventory1; /** * * @author Gary */ public class Inventory1 { public static void main(String args []) { class dvd { public dvd(int i, String Matrix, int i0, double dvd) { } } DVD dvd; Object DVD dvd = new DVD (1, "Matrix", 5, 2.15); System.out.println(dvd); DVD dvd1 = new DVD (2,"Aliens", 7, 1.23); System.out.println(dvd); DVD = new dvd (3, "Twilight", 6, 3.65); System.out.println(dvd); DVD = new dvd (4, "Hurt Locker", 3, 2.10); System.out.println(dvd); System.out.println("Product Title is " + dvd.getDvdTitle()); System.out.println("The number of units in stock is" + dvd.getDvdStock()); System.out.println("The price of each DVD is" + dvd.getDvdPrice()); System.out.println("The item number is " + dvd.getDvdItem()); System.out.println("The value of the inventory is" + dvd.value()); } //end main } // end class Inventory1 class DVD { private String dvdTitle; private double dvdStock; private double dvdPrice; private double dvdItem; public DVD(String title, double stock, double price, double item) { dvdTitle = title; dvdStock = stock; dvdPrice = price; dvdItem = item; } //end four-argument constructor // set DVD name public void setDvdTitle(String title) { dvdTitle = title; } //end method setDvdTitle //return DVD Title public String getDvdTitle() { return dvdTitle; } //end method getDvdTitle //set DVD Stock public void setDvdStock(double stock) { dvdStock = stock; } //end method setDvdStock //return DvdStock public double getDvdStock() { return dvdStock; } //end method get Dvdstock public void setDvdPrice(double price) { dvdPrice = price; } //end method setDvdPrice //return dvdPrice public double getDvdPrice() { return dvdPrice; } //end method get Dvd Price public void setDvdItem(double item) { dvdItem = item; } //end method setdvdItem //return DVD item public double getDvdItem() { return dvdItem; } //end method getDvdItem //calculate inventory value public double value() { return dvdPrice * dvdStock; } //end method value } //end class DVD