這是我用於我的項目的類文件的當前代碼,我得到兩個標識符預期的錯誤與公共雙highStoreSales(商店)和公共雙double averageStoreSales(季度)類文件錯誤:「標識符預期」
我在想什麼?
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);
}
}
第1步:格式一致的,合理的代碼縮進。 *編輯*:在這個場合我已經爲你做了。 –
我也輸入了多少? – user2985542
@ user:問題應該*特定*(如您原來的那樣)和個人。發佈關於其他事情的後續問題並不是它工作的方式。如果您有其他問題,請單獨發佈,並附上所有必要的上下文。 –