New To Java - null

This is what my professor wants us to do

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.

The error I keep getting when I try to compile it is :

C:\IT215\Inventory2.java:98: illegal start of expression

private static void printArray(DVD[] myDVD) {

^

C:\IT215\Inventory2.java:179: reached end of file while parsing

}2 errors

Here is the code

//InventoryProgram2

//Inventory2.java

//author Michelle

//IT/215-Java Programming

//Mar. 29, 2007

//This program stores information for inventory products, uses an array to store products, and calculates inventory

import java.util.Scanner; // program uses class Scanner

import java.io.*;

import java.util.*;

public class Inventory2

{

// main method begins execution of Java application

public static void main( String args[] )throws IOException {

{

DVD dvd;

Inventory inventory = new Inventory();

// create Scanner to obtain input from command window

Scanner input = new Scanner( System.in );

String dvdName; // name of dvd

int itemNumber; // identification number for product

float itemPrice; // first number to multiply

float itemUnits; // second number to multiply

float inventoryValue; // inventory value of number1 and number2

System.out.println("\nEnter a collection of DVDs...");

System.out.print( "Enter dvd name: " ); // prompt

dvdName = input.nextLine(); // read dvd name from user

System.out.print( "Enter item number: " ); // prompt

itemNumber = input.nextInt(); // read item number from user

System.out.print( "Enter item price : " ); // prompt

itemPrice = input.nextFloat(); // read first number from user

System.out.print( "Enter item unit : " ); // prompt

itemUnits = input.nextFloat(); // read second number from use

inventoryValue = itemPrice * itemUnits; // multiply numbers

DVD dvd = new DVD(dvdName, itemNumber, itemPrice, itemUnits);

inventory.add(dvd);

System.out.printf("\n\nItem Name:%s\n", dvd.getitemName()); //display item name

System.out.printf("Item Number:%s\n", dvd.getItemNumber()); //display item number

System.out.printf("Quantity in Stock:%s\n",dvd.getStockQuantity()); //display quantity in stock

System.out.printf("Item Price:$%.2f\n",dvd.getItemPrice()); //display item price

System.out.printf("Value of Inventory:$%.2f\n",dvd.calculateInventoryValue()); //display total value of inventory for this item

} // end method main

} // end class inventory2

class Inventory

{

private DVD[] dvds;

private int count;

Inventory()

{

dvds = new DVD[100];

count = 0;

}

public void add(DVD dvd)

{

dvds[count++] = dvd;

}

public float getTotalValue()

{

float total = 0;

for(DVD d : dvds)

myDVD = new DVD[5];

myDVD[0] = new DVD("Black Christmas",1,15,200);

myDVD[1] = new DVD("**** and Jane",2,21,350);

myDVD[2] = new DVD("Epic Movie",3,20,100);

myDVD[3] = new DVD("Ghost",4,12,120);

myDVD[4] = new DVD("Titanic",5,14,210);

printArray(myDVD);

myDVD = sortArray(myDVD);

System.out.println(" Here is the Array Sorted \n\n");

printArray(myDVD);

private static void printArray(DVD[] myDVD) {

for (int i = 0; i<5;++i){

System.out.println ("\nThe DVD number " + i + " name is "+ myDVD.getName() );

System.out.println("The inventory Value is " + myDvd.calculateInventoryValue());

total = myDvd.calculateInventoryValue() + total;

} // End For Loop

System.out.println ("The total of all inventory is " + total);

} // printArray Method

private static DVD[] sortArray(DVD[] myDVD) {

DVD temp= new DVD();

int i, j;

int array_size = 5;

for (i = (array_size - 1); i >= 0; i--){

for (j = 1; j <= i; j++){

if (myDVD[j-1].getName().compareTo(myDVD[j].getName()) > 1){

temp = myDVD[j-1];

myDVD[j-1] = myDVD[j];

myDVD[j] = temp;

} // end if

} // end inner for loop

} // End outer for loop

return myDVD;

} // end method

} // end class

class DVD

{

public String name;

public int itemNumber;

public float itemPrice;

public float itemUnits;

DVD(String newName, int newItemNumber, float newItemPrice, float newItemUnits)

{

name = newName;itemNumber = newItemNumber;

itemPrice = newItemPrice;itemUnits = newItemUnits;

}

public void setItemName(String name) // Method to set the item name

{

this.name = name;

}

public String getItemName() { return name; }

public void setItemNumber(int number) // Method to set the item number

{

this.itemNumber = number;

}

public int getItemNumber() { return itemNumber; }

public void setStockQuantity(long quantity) // Method to set the quantity in stock

{

itemUnits = quantity;

}

public float getStockQuantity() { return itemUnits; }

public void setItemPrice(float price) // Method to set the item price

{

this.itemPrice = price;

}

public float getItemPrice() { return itemPrice; }

public float calculateInventoryValue()

{

return itemUnits * itemPrice;

}

public int compareTo(Object o)

{

DVD d = (DVD)o;

return name.compareTo(d.getItemName());

}

public String toString()

{

return "Name: " + name + "\nNumber: " + itemNumber + "\nPrice: $" + itemPrice +

"\nQuantity: " + itemUnits + "\nValue: $" + calculateInventoryValue();

[6386 byte] By [mlb_25a] at [2007-11-26 23:32:40]
# 1
its very hard to look at the code without code tags, i would guess, it is because you are missing some brackets some where. Which results in compiler assuming that you are defining methods inside of other methods
kilyasa at 2007-7-10 14:45:23 > top of Java-index,Java Essentials,New To Java...
# 2

its very hard to look at the code without code tags,

i would guess, it is because you are missing some

brackets some where. Which results in compiler

assuming that you are defining methods inside of

other methods

Excellent guess:

printArray (myDVD);

/******* There should be a } here ******/

private static void printArray (DVD[] myDVD)

{

CSAngela at 2007-7-10 14:45:23 > top of Java-index,Java Essentials,New To Java...