Here is my assignment:Choose a product that lends itself to an inventory (for example, products at your
workplace, office supplies, music CDs, DVD movies, or software).
• Create a product class that holds the item number, the name of the product, the number
of units in stock, and the price of each unit.
• Create a Java application that displays the product number, the name of the product, the
number of units in stock, the price of each unit, and the value of the inventory (the
number of units in stock multiplied by the price of each unit). Pay attention to the good
programming practices
Here is what i have so far:
package javaapplication24;
import java.util.Arrays;
class inventoryList
{
public static void main( String args[] )
{
final int arrayLength=5;
int dvdNumber[] = new int[arrayLength];
String dvdName[] = new String[] {"Sweet Home Alabama", "How to Loose a Guy in 10 Days",
"Ps I love You", "Freedom Writters", "Hannah Montana"};
int dvdUnits[] = {5, 3, 2, 2, 3};
double dvdPrice[] = {19.95, 19.95, 15.95, 15.95, 19.95};
double dvdValue[] = new double[arrayLength];
sortcdName(dvdName);
for(int counter = 0; counter < dvdNumber.length; counter++)
System.out.println("\nDVD Item:"+(dvdNumber[counter]=1+counter)+
"\nDVD Name:"+dvdName[counter]+
"\nNumber of Units:"+dvdUnits[counter]+
"\nPrice per DVD:\u0024"+dvdPrice[counter]+
"\nCD Value:\u0024"+(dvdValue[counter]=dvdUnits[counter]*dvdPrice[counter]));
outputTotalValue(dvdValue);
}
public static void outputTotalValue(double cdValue[])
{
double totalDVDValue = 0;
for(int counter = 0; counter<dvdValue.length; counter++)
totalDVDValue += dvdValue[counter];
System.out.printf( "\nTotal Value of all Stock: \u0024"+totalDVDValue+"\n\n" );
}
public static void sortcdName( String dvdName[])
{
Arrays.sort(dvdName);
}