java错误 - 这是什么意思? [英] java errors - what does this mean??
问题描述
预期课程,界面或枚举
DVD CLASS
^
类,接口或枚举预期
DVDINVENTORY CLASS
^
如何在没有其他错误的情况下修复这两个错误???
>
这是我的代码:
DVD 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 getProductNumber(){return产品编号; } $ / $
public String getItemName(){return itemName; } $ / $
public int getNumberOfUnits(){return numberOfUnits; }
public double getPricePerUnit(){return pricePerUnit; }
public double calculateInventoryValue(){
返回numberOfUnits * pricePerUnit;
}
}
DVDINVENTORY CLASS
import java.util.Scanner;
公共类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.println(dvd); }
System.out.println(库存价值:$+ calculateInventoryValue(myDvds));
}
private static Dvd readDvd(){
Scanner in = new Scanner(System.in);
System.out.print("输入项目名称或\ quit \停止:");
String itemName = in.nextLine();
if(itemName.equalsIgnoreCase(" quit") ){return null; }
System.out.print("输入产品编号:");
String productNumber = in.nextLine();
System.out.print(" Enter number of units:");
int numberOfUnits = in.nextInt();
System.out.print("输入每单位价格:);
double pricePerUnit = in.nextDouble();
返回新的Dvd(productNumber,itemName,numberOfUnits);
}
private static double calculateInventoryValue(Dvd [] dvds){
double result = 0;
for( Dvd dvd:dvds){result + = dvd.calculateInventoryValue(); }
返回结果;
}
}
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 getProductNumber() { return productNumber; }
public String getItemName() { return itemName; }
public int getNumberOfUnits() { return numberOfUnits; }
public double getPricePerUnit() { return pricePerUnit; }
public double calculateInventoryValue() {
return numberOfUnits*pricePerUnit;
}
}
DVDINVENTORY CLASS
import java.util.Scanner;
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.println(dvd); }
System.out.println("Value of Inventory: $ "+calculateInventoryValue(myDvds));
}
private static Dvd readDvd() {
Scanner in = new Scanner(System.in);
System.out.print("Enter item name or \"quit\" to stop: ");
String itemName = in.nextLine();
if(itemName.equalsIgnoreCase("quit")) { return null; }
System.out.print("Enter product number: ");
String productNumber = in.nextLine();
System.out.print("Enter number of units: ");
int numberOfUnits = in.nextInt();
System.out.print("Enter price per unit: ");
double pricePerUnit = in.nextDouble();
return new Dvd(productNumber,itemName,numberOfUnits);
}
private static double calculateInventoryValue(Dvd[] dvds) {
double result = 0;
for(Dvd dvd : dvds) { result += dvd.calculateInventoryValue(); }
return result;
}
}
推荐答案
" + calculateInventoryValue(myDvds));
}
private static Dvd readDvd(){
Scanner in = new扫描仪(System.in);
System.out.print("输入项目名称或\" quit \"停止:");
String itemName = in.nextLine();
if(itemName.equalsIgnoreCase(" quit")){return null; }
System.out.print("输入产品编号:");
String productNumber = in.nextLine();
System.out.print(" Enter number of units:");
int numberOfUnits = in.nextInt();
System.out.print("输入每单位价格:);
double pricePerUnit = in.nextDouble();
返回新的Dvd(productNumber,itemName,numberOfUnits);
}
private static double calculateInventoryValue(Dvd [] dvds){
double result = 0;
for( Dvd dvd:dvds){result + = dvd.calculateInventoryValue(); }
返回结果;
}
}
"+calculateInventoryValue(myDvds));
}
private static Dvd readDvd() {
Scanner in = new Scanner(System.in);
System.out.print("Enter item name or \"quit\" to stop: ");
String itemName = in.nextLine();
if(itemName.equalsIgnoreCase("quit")) { return null; }
System.out.print("Enter product number: ");
String productNumber = in.nextLine();
System.out.print("Enter number of units: ");
int numberOfUnits = in.nextInt();
System.out.print("Enter price per unit: ");
double pricePerUnit = in.nextDouble();
return new Dvd(productNumber,itemName,numberOfUnits);
}
private static double calculateInventoryValue(Dvd[] dvds) {
double result = 0;
for(Dvd dvd : dvds) { result += dvd.calculateInventoryValue(); }
return result;
}
}
这里是我的代码:
here is my code:
我认为你应该摆脱那个序言。为什么你首先将它添加到你的来源
代码?
亲切的问候,
Jos
I think you should get rid of that preamble. Why did you prepend it to your source
code in the first place?
kind regards,
Jos
我是java新手...嗯我不知道你的意思??
im new to java...umm i dont know what you mean??
这篇关于java错误 - 这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!