I realize this code has been seen a million times already. I am trying to 'start' on part 3 of this. I do not wish for it to be done for me just a starting point for this subclass. These are the directions:
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.
This is what I have to start with:
import java.util.Scanner;
//Inventory program
//This program monitors DVD inventory, price, and stock
public class Inventory
{//new class inventory
public static void main (String args[])
{//begin main method
System.out.print("Welcome to the DVD inventory program");//welcome
System.out.println();//blank line
System.out.println("This program monitors DVD inventory, price, and stock.");//program purpose
System.out.println();//blank line
//declare variables
String DvdTitle;
double ItemNumber = 0.00;
double DvdPrice = 0.00;
int NumberInStock = 0;
int count;//counter control variable
Scanner input = new Scanner (System.in);
System.out.println("How many DVDs would you like to enter?");//prompt for length of array
count = input.nextInt();//accept user input
//declare arrays
String[] DvdTitleArray = new String[count];
double[] ItemNumberArray = new double[count];
double[] DvdPriceArray = new double[count];
int[] NumberInStockArray = new int[count];
double[] StockValueArray = new double[count];
for (int i = 0; i<count; i++)
{
System.out.println();//blank line
System.out.println("Enter title of DVD. ");//prompt for title
DvdTitle = input.next();//accept user input
DvdTitleArray[i] = DvdTitle;
System.out.println();//blank line
System.out.println("Please enter item Number.");//request item number
ItemNumber = input.nextDouble();//user input item number as double
ItemNumberArray[i] = ItemNumber;
System.out.println();//blank line
System.out.println("Please enter price of DVD.");//request price
DvdPrice = input.nextDouble();//accept user input
DvdPriceArray[i] = DvdPrice;
if (DvdPrice <=0)
{//if statement for if price is equal or less than "0"
System.out.println("Invalid price entry");
System.out.println();//blank line
System.out.println("Please reenter valid price.");
DvdPrice = input.nextDouble();//accept user input
DvdPriceArray[i] = DvdPrice;
}//end if
else
System.out.println();//blank line
System.out.println("Please enter number of DVDs in stock.");//request number of DVDs in staock
NumberInStock = input.nextInt();//accept user input
NumberInStockArray[i] = NumberInStock;
StockValueArray[i] = (DvdPrice * NumberInStock);
}//end for
double totalInventory = computeValue(StockValueArray);
for (int i = 0; i<count; i++)
{//print information from array
System.out.println("DVD Title:" + DvdTitleArray[i]);
System.out.println("Item Number:" + ItemNumberArray[i]);
System.out.println("Price:" + DvdPriceArray[i]);
System.out.println("Number in Stock:" + NumberInStockArray[i]);
System.out.println("Stock Value:" + StockValueArray[i]);
System.out.println();//blank line
}//end for
System.out.println("Total Inentory:" +totalInventory);
}//end main method
private static double computeValue (double[] StockValueArray)
{
double StockValue = 0.00;
for (int i = 0; i<StockValueArray.length; i++)
{
StockValue += StockValueArray[i];
}
return StockValue;
}//end method
}//end inventory class