OK, so I'm very new to Java programming and I've been able to squeek by so far, but I'm completely stuck on this assignment. Here is the assignment that is due this week -
• Modify the Inventory Program so the application can handle multiple items. 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. DON'T use array.sort.
Compile and run the Java program.
And here is my code from last week -
Can somebody please help me get to the next step!! Many thanks in advance!! :)
• Modify the Inventory Program so the application can handle multiple items. 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. DON'T use array.sort.
Compile and run the Java program.
And here is my code from last week -
Code:
//Inventory Program Part 1 class Inventory { private String Name; //stores DVD name private long itemNumber; //stores item number private long stockQuantity; //stores quanity in stock private double dvdPrice; //stores DVD price public Inventory () { Name = ""; itemNumber = 0L; stockQuantity = 0L; dvdPrice = 0.0; } public Inventory (String Name, long itemNumber, long stockQuantity, double dvdPrice) { this.Name = Name; this.itemNumber = itemNumber; this.stockQuantity = stockQuantity; this.dvdPrice = dvdPrice; } public void setItemName(String Name) //Method to set and get the item name { this.Name = Name; } public String getItemName() { return Name; } public void setItemNumber(long itemNumber) //Method to set and get the item number { itemNumber = itemNumber; } public long getItemNumber() { return itemNumber; } public void setStockQuantity(long quantity) //Method to set and get the quantity in stock { stockQuantity = stockQuantity; } public long getStockQuantity() { return stockQuantity; } public void setItemPrice(double dvdPrice) //Method to set and get the item price { this.dvdPrice = dvdPrice; } public double getItemPrice() { return dvdPrice; } public double calculateInventoryValue() //Method to calculate the value of the in stock inventory { return dvdPrice * stockQuantity; } }//end class Inventory public class Inventory1 { public static void main( String args[]) { Inventory p = new Inventory("24: Season 4", 1, 10, 24.99); //Lists 1st DVD inventory information System.out.println(); System.out.print( "Inventory of DVD Movies: " ); //display title System.out.printf("\n\nDVD Title: %s\n",p.getItemName()); //display DVD title System.out.printf("Item Number: %s\n",p.getItemNumber()); //display item number System.out.printf("Quantity in Stock: %s\n",p.getStockQuantity()); //display quantity in stock System.out.printf("Item Price: $%.2f\n",p.getItemPrice()); //display DVD price System.out.printf("Inventory Value: $%.2f\n",p.calculateInventoryValue()); //display total value of inventory for item System.out.println(); System.out.println(); } }//end class Inventory1
Comment