这是我目前用于我的项目的类文件的代码,我在公共双highStoreSales(store)和public double averageStoreSales(quarter)的行上得到两个标识符预期错误
我缺少什么?
import java.io.File;
import java.text.DecimalFormat;
import java.util.Scanner;
import java.io.IOException;
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class SalesAnaylzer //extends SalesManager
{
DecimalFormat pricePattern = new DecimalFormat("$#0.00");
int[][] sales = new int[3][4];
public SalesAnaylzer(String fileName) throws IOException {
File inputFile = new File(fileName);
Scanner scan = new Scanner(inputFile);
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 6; col++) {
sales[row][col] = scan.nextInt();
}
}
}
public String toString() {
String data = "";
for (int row = 0; row < 4; row++) {
data = data + "\nStore " + (row + 1) + ": ";
for (int col = 0; col < 6; col++) {
data = data + "QTR " + (col + 1) + ": " + pricePattern.format(sales[row][col]) + " ";
}
}
return data;
}
public double totalSales() {
double total = 0.0;
for (int row = 0; row < 4; row++) {
for (int col = 0; col < 6; col++) {
total = total + sales[row][col];
}
}
return total;
}
public double highStoreSales(store) {
double highest = 0.0;
for (int row = 0; row < 4; row++) {
if (sales[row][store] > highest)
highest = sales[row][store];
}
return pricePattern.format(highest);
}
public double averageStoreSales(quarter) {
double total = 0.0;
double avg = 0.0;
for (int col = 0; col < 6; col++) {
total = total + sales[quarter][col];
}
avg = (total / 4);
return pricePattern.format(avg);
}
}
答案 0 :(得分:3)
你有没有类型的参数名称,例如:
public double averageStoreSales(quarter)
您需要说出quarter
的类型,例如:
public double averageStoreSales(int quarter)
// -----------------------------^