Here is my code for a working program that I need to sort the output by the DVD's Title
//
import java.util.*;
import java.text.*;
import java.io.*;
public class InventoryApp2 {
public static void main(String args [])
{
Scanner input = new Scanner(System.in);
// Set the size of the array based on user input
System.out.println( "Please enter the number of DVD's to record: " );
int numDVD = input.nextInt();
//Create employee array to store data
DVDRuntime[] dvd = new DVDRuntime[numDVD];
for (int i=0; i<numDVD; i++)
{
input = new Scanner(System.in);
// input the DVD Title
System.out.println( "\n\nPlease enter the Title for DVD # " + (i + 1) +": " );
String dvdTitle = input.nextLine();
// Input the DVD's item number
System.out.println( "\nPlease enter the item number for \nDVD # " + (i + 1) +": " );
int dvdItem = input.nextInt();
// Input the DVD's quantity on hand
System.out.println( "\nPlease enter the quantity on hand for DVD # " + (i + 1) +": " );
int dvdStock = input.nextInt();
// Input the Price for the DVD
System.out.println( "\nPlease enter the price for DVD # " + (i + 1) +": " );
double dvdPrice = input.nextDouble();
dvd[i] = new DVDRuntime(dvdItem, dvdTitle, dvdStock, dvdPrice);
//Input the Run-time for the DVD
System.out.println("\nPlease enter runtime length of the DVD in minutes: ");
dvd[i].setRuntime(input.nextDouble());
}
//Print DVD data
double totalInventoryValue=0;
for (int i=0; i<numDVD; i++)
{
System.out.println(dvd[i]);
System.out.println("Runtime length: "+dvd[i].getRuntime() +" Minutes");
System.out.println("Value of this title stock: "+dvd[i].getTotal());
//clculating total value of inventory
totalInventoryValue += dvd[i].getTotal();
}
System.out.println("\nTotal value of inventory: "+totalInventoryValue);
System.out.println("\nTotal value of inventory with 5% restocking fee: "+
(totalInventoryValue*1.05));
} //end main
} // end class Inventory2
and
//
import java.util.*;
import java.text.*;
import java.io.*;
public class DVD
{
private int dvdItem;
private String dvdTitle;
private int dvdStock;
private double dvdPrice;
private double getTotal;
public DVD(int item, String title, int stock, double price)
{
dvdItem = item;
dvdTitle = title;
dvdStock = stock;
dvdPrice = price;
} //end four-argument constructor
//default constructor
public DVD(){}
// set DVD Item
public void setDvdItem(int item) {
this.dvdItem = item;
} //end method set Dvd Item
//return DVD Item
public int getDvdItem() {
return dvdItem;
} //end method get Dvd Item
//set DVD Title
public void setDvdTitle(String title) {
this.dvdTitle = title;
} //end method set Dvd Title
//return Dvd Title
public String getDvdTitle() {
return dvdTitle;
} //end method get Dvd Title
public void setDvdStock(int stock) {
this.dvdStock = stock;
} //end method set Dvd Stock
//return dvd Stock
public int getDvdStock() {
return dvdStock;
} //end method get Dvd Stock
public void setDvdPrice(double price) {
this.dvdPrice = price;
} //end method setdvdPrice
//return DVD Price
public double getDvdPrice() {
return dvdPrice;
} //end method get Dvd Price
public double getTotal(){
return dvdPrice*dvdStock;
}
public String toString()
{
return ("\n" + "Title: " + this.dvdTitle + "\n"
+ "Stock Number: " + this.dvdItem + "\n"
+ "Quantity on hand: " + this.dvdStock +"\n"
+ "Price per unit: " + this.dvdPrice );
}
} //end class DVD
and
//
public class DVDRuntime extends DVD{
double runtime;
public double getRuntime() {
return runtime;
}
public void setRuntime(double runtime) {
this.runtime = runtime;
}
//defualt constructor
public DVDRuntime(){}
//parameterized
public DVDRuntime(int item, String title, int stock, double price)
{
super( item, title, stock, price);
}
}
thanks