class, interface, or enum expected
DVD CLASS
^
class, interface, or enum expected
DVDINVENTORY CLASS
^
HOW DO I FIX THESE TWO ERRORS WITHOUT GETTING OTHER ERRORS???
here is my code:
DVD CLASS
public class Dvd {
private String productNumber;
private String itemName;
private int numberOfUnits;
private double pricePerUnit;
public Dvd(String prodNo, String name, int noUnits, double price) {
productNumber = prodNo;
itemName = name;
numberOfUnits = noUnits;
pricePerUnit = price;
}
public String getProductNumbe r() { return productNumber; }
public String getItemName() { return itemName; }
public int getNumberOfUnit s() { return numberOfUnits; }
public double getPricePerUnit () { return pricePerUnit; }
public double calculateInvent oryValue() {
return numberOfUnits*p ricePerUnit;
}
}
DVDINVENTORY CLASS
import java.util.Scann er;
public class DvdInventory {
public static void main(String[] args) {
int SIZE = 100;
Dvd[] myDvds = new Dvd[SIZE];
int numberOfDvds = 0;
while (numberOfDvds < SIZE) {
Dvd dvd = readDvd();
if(dvd == null) { break; }
myDvds[numberOfDvds++] = dvd;
}
for(Dvd dvd : myDvds) { System.out.prin tln(dvd); }
System.out.prin tln("Value of Inventory: $ "+calculateInve ntoryValue(myDv ds));
}
private static Dvd readDvd() {
Scanner in = new Scanner(System. in);
System.out.prin t("Enter item name or \"quit\" to stop: ");
String itemName = in.nextLine();
if(itemName.equ alsIgnoreCase(" quit")) { return null; }
System.out.prin t("Enter product number: ");
String productNumber = in.nextLine();
System.out.prin t("Enter number of units: ");
int numberOfUnits = in.nextInt();
System.out.prin t("Enter price per unit: ");
double pricePerUnit = in.nextDouble() ;
return new Dvd(productNumb er,itemName,num berOfUnits);
}
private static double calculateInvent oryValue(Dvd[] dvds) {
double result = 0;
for(Dvd dvd : dvds) { result += dvd.calculateIn ventoryValue(); }
return result;
}
}
DVD CLASS
^
class, interface, or enum expected
DVDINVENTORY CLASS
^
HOW DO I FIX THESE TWO ERRORS WITHOUT GETTING OTHER ERRORS???
here is my code:
DVD CLASS
public class Dvd {
private String productNumber;
private String itemName;
private int numberOfUnits;
private double pricePerUnit;
public Dvd(String prodNo, String name, int noUnits, double price) {
productNumber = prodNo;
itemName = name;
numberOfUnits = noUnits;
pricePerUnit = price;
}
public String getProductNumbe r() { return productNumber; }
public String getItemName() { return itemName; }
public int getNumberOfUnit s() { return numberOfUnits; }
public double getPricePerUnit () { return pricePerUnit; }
public double calculateInvent oryValue() {
return numberOfUnits*p ricePerUnit;
}
}
DVDINVENTORY CLASS
import java.util.Scann er;
public class DvdInventory {
public static void main(String[] args) {
int SIZE = 100;
Dvd[] myDvds = new Dvd[SIZE];
int numberOfDvds = 0;
while (numberOfDvds < SIZE) {
Dvd dvd = readDvd();
if(dvd == null) { break; }
myDvds[numberOfDvds++] = dvd;
}
for(Dvd dvd : myDvds) { System.out.prin tln(dvd); }
System.out.prin tln("Value of Inventory: $ "+calculateInve ntoryValue(myDv ds));
}
private static Dvd readDvd() {
Scanner in = new Scanner(System. in);
System.out.prin t("Enter item name or \"quit\" to stop: ");
String itemName = in.nextLine();
if(itemName.equ alsIgnoreCase(" quit")) { return null; }
System.out.prin t("Enter product number: ");
String productNumber = in.nextLine();
System.out.prin t("Enter number of units: ");
int numberOfUnits = in.nextInt();
System.out.prin t("Enter price per unit: ");
double pricePerUnit = in.nextDouble() ;
return new Dvd(productNumb er,itemName,num berOfUnits);
}
private static double calculateInvent oryValue(Dvd[] dvds) {
double result = 0;
for(Dvd dvd : dvds) { result += dvd.calculateIn ventoryValue(); }
return result;
}
}
Comment