I have an assignment that is due tonight and I ran into a few errors. The first two parts compiled successfully just the third one ran into errors. I don't know what went wrong. The errors I am getting are
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:51: error: cannot find symbol
NumberFormat nfc = NumberFormat.getCurrencyInstance(Locale.US);
^
symbol: class NumberFormat
location: class inventoryTest
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:51: error: cannot find symbol
NumberFormat nfc = NumberFormat.getCurrencyInstance(Locale.US);
^
symbol: variable Locale
location: class inventoryTest
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:51: error: cannot find symbol
NumberFormat nfc = NumberFormat.getCurrencyInstance(Locale.US);
^
symbol: variable NumberFormat
location: class inventoryTest
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:80: error: cannot find symbol
Scanner input = new Scanner( System.in );
^
symbol: class Scanner
location: class inventoryTest
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:80: error: cannot find symbol
Scanner input = new Scanner( System.in );
^
symbol: class Scanner
location: class inventoryTest
C:\Users\Owner\Desktop\Inventory Part 3\inventoryTest.java:123: error: cannot find symbol
DVD = new DVD(name,number,price,stock,supplier);
^
symbol: variable DVD
location: class inventoryTest
public class inventory
{
//Variable specifications
private String productName; // Is what stores the product name
private int productID; // Is what stores the product ID/number
private long unitsInStock; // Is what stores the number of product units in stock
private float unitPrice; // Is what stores the unit price of the product
// Constructor for a product that is not specified
inventory()
{
setName("UNKNOWN");
setProductID(0);
setUnitPrice(0);
setUnitsInStock(0);
}
// Constructor for a product with a supplied name, ID/number, unit price, and number of units in stock
inventory(String productName, int productID, float unitPrice, long unitsInStock)
{
setName(productName);
setProductID(productID);
setUnitPrice(unitPrice);
setUnitsInStock(unitsInStock);
}
// Method that sets the name of the product
public void setName (String productName)
{
this.productName = productName;
}
// Method that sets the ID/number of the product
public void setProductID (int productID)
{
this.productID = productID;
}
// Method that sets the unit price of the product
public void setUnitPrice (float unitPrice)
{
this.unitPrice = unitPrice;
}
// Method that sets the number of product units in stock
public void setUnitsInStock (long unitsInStock)
{
this.unitsInStock = unitsInStock;
}
// Method that retrieves the name of the product
public String getName()
{
return productName;
}
// Method that retrieves the product ID/number
public int getProductID()
{
return productID;
}
// Method that retrieve the number of product units in stock
public long getUnitsInStock()
{
return unitsInStock;
}
// Method that retrieves the unit price of the product
public float getUnitPrice()
{
return unitPrice;
}
// Method computes and returns the total inventory value of the product
public float getTotalValue()
{
return (unitsInStock * unitPrice);
}
} // end class inventory
public class DVD extends inventory
{
private String supplier;
private float restockfee;
DVD()
{
super();
supplier = "Unknown";
restockfee = 0;
}
DVD(String productName, int productID, float unitPrice, long unitsInStock, String supplier)
{
super(productName, productID, unitPrice, unitsInStock);
this.supplier = supplier;
}
public String getSupplier()
{
return supplier;
}
public void setProducer(String supplier)
{
this.supplier = supplier;
}
public float getRestockFee()
{
return restockfee;
}
public float getTotalValue()
{
restockfee = (5*super.getTotalValue())/100;
//added 5% restocking fee
return (super.getTotalValue() + restockfee);
}
} //ends class DVD
public class inventoryTest
{
final int MAX = 5;
DVD pt[] = new DVD[MAX];
int numberOfDVD = 0;
//this method sorts the array accoding to the names (Sorting technique: Bubble Sort)
public void arraySort(int count)
{
int pass , i;
int temp;
DVD s = null;
//start sorting if we have more than 1 individual record in array
if(count > 1)
{
//make count - 1 passes through the array
for(pass=1; pass<count; pass++)
{
//in each pass shift largest element to right most position
for(i=0; i<count-pass; i++)
{
//comparing the names of Individuals
temp = (pt[i].getName()).compareTo(pt[i+1].getName());
if( temp > 0)
{
//if name at i position of array is greater than one at i+1 position than swap
s = pt[i];
pt[i] = pt[i+1];
pt[i+1] = s;
}//if ends
}//second for loop ends
}//first for loop ends
}//if condition ends
}
// Method calculates and returs the total value of inventory of all items
public float totalValueOfInventory()
{
float totalValue = 0;
for(int i=0; i<numberOfDVD; i++)
{
totalValue = totalValue + pt[i].getTotalValue();
}
return totalValue;
}
//Method that displays one product at time and total value of all inventory
public void displayDVD(int index)
{
// Set Currency to U.S. Dollars
NumberFormat nfc = NumberFormat.getCurrencyInstance(Locale.US);
// display one DVD
System.out.println( "Name: " + pt[index].getName() );
System.out.println( "ID: " + pt[index].getProductID() );
System.out.println( "Unit Price: " + nfc.format( pt[index].getUnitPrice() ) );
System.out.println( "Units in Stock: " + pt[index].getUnitsInStock() );
System.out.println( "Total Product Value: " + nfc.format( pt[index].getTotalValue() ) );
System.out.println( "Manufacturer: " + pt[index].getSupplier() );
System.out.println( "Restocking Fee: " + nfc.format(pt[index].getRestockFee()) );
System.out.println( "\nTotal Value of Inventory: " + nfc.format( totalValueOfInventory() ) );
System.out.println();
}
//main method
public static void main( String args[] )
{
//variables for accepting data
String name;
int number;
long stock;
float price;
String supplier;
//create an object inventoryTest class
inventoryTest tip = new inventoryTest();
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
// Show Program Welcome Message
System.out.println( ); // Show an Empty Line
System.out.println( "Welcome to Inventory Program Part 3!"); // Show Welcome Message
System.out.println( ); // Show an Empty Line
// Create a reference
DVD dvd;
//this loop continues to accept information until user enters "stop" as product name
while(true)
{
// Show an Empty Line
System.out.println( );
// Prompt for Product Name
System.out.print( "Enter a Product Name(or STOP to End Program): " ); // prompt message
name = input.nextLine(); // read the product name
if(name.equalsIgnoreCase("stop")) //check whether user entered "stop"
{
break; //breaks while loop
}
// Prompt for Product ID
System.out.print( "Enter a Product ID: " ); // prompt message
number = input.nextInt(); // read the product ID
// Prompt for Product's Unit Price
System.out.print( "Enter the Product's Unit Price ($): " ); // prompt message
price = input.nextFloat(); // read the product's unit price
// Prompt for Product's Stock Inventory
System.out.print( "Enter the Number of Product Units in Stock: " ); // prompt message
stock = input.nextLong(); // read the number of product units in stock
input.nextLine(); // Need this to get leftover carriage return
// Prompt for supplier
System.out.print( "Enter Product Producer: " ); // prompt message
supplier = input.nextLine(); // read the supplier
//create new inventory
DVD = new DVD(name,number,price,stock,supplier);
if(tip.numberOfDVD < tip.MAX) //check whether the array is full or not
{
tip.pt[tip.numberOfDVD] = dvd;
tip.numberOfDVD++;
System.out.println( ); // Show an Empty Line
System.out.println( "Inventory Information Added" );
tip.displayDVD(tip.numberOfDVD - 1);
}
else
{
System.out.println("\nArray is full. Please stop entering more information.");
}
}//end infinite while loop
//sort the array
tip.arraySort(tip.numberOfDVD);
//display the sorted array
System.out.println("\nInventory Sorted\n");
for(int i = 0; i < tip.numberOfDVD; i++)
{
tip.displayDVD(i);
}
} // end method main
}//ends class