
I am taking my first Java class. In class we are making a DVD inventory program using an array and calculating the total of the entire inventory at the end. My total does not seem to be working, can you please help me to display the total of the inventory in my program::
import java.util.Scanner;
public class DVDWk6B
{
public static void main( String args[] )
{
// c Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
String dvdName[] = new String[200];
int upc[] = new int[200];
double price[] = new double[200]; // price per item
double qty[] = new double[200]; // total qty
double inventory[] = new double[200]; // total inventory
int itemIndex = 0; // product index
System.out.print("DVD Title or type Stop to quit program.");
dvdName [itemIndex] = input.nextLine();
while (!dvdName[itemIndex].equals("stop")) // check for exit prompt
{
System.out.print("Enter UPC.");
upc [itemIndex] = input.nextInt();
System.out.println( "Price per DVD: " ); // prompt
price [itemIndex] = input.nextDouble(); // read price
System.out.print("Qty: ");
qty [itemIndex] = input.nextDouble();
itemIndex = itemIndex + 1; // increment index by 1
input.nextLine(); // clears input buffer
System.out.print( "DVD Name or stop to terminate: " ); // prompts user for next product item input
dvdName[itemIndex] = input.nextLine(); // gets next product name input from user
// while (qty <= -1) same as above, not really needed
//qty [itemIndex] = input.nextDouble(); // read price
}
// prints output headings
System.out.printf( "%s\t%s\t%s\t%s\t%s\t%s\n", "Index", "DVD Title", "UPC Code", "Qty", "Unit Cost", "Inventory Value");
// print list with inventory values
for (int index = 0; index < itemIndex; index++)
System.out.printf( "%5d\t%-12s\t%-9d\t%-5.2f\t$%-10.2f\t$%-14.2f\n", index+1, dvdName[index], upc[index],qty[index],price[index],
(qty[index] * price[index]));
System.out.print("Total Inventory:"(qty * price));
}//end main method
}