Reputation: 61
Here is my current code of the class file i am using for my project, Im getting two identifier expected errors on the lines with public double highStoreSales(store) and public double averageStoreSales(quarter)
What am i missing?
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);
}
}
Upvotes: 0
Views: 779
Reputation: 1075467
You have argument names without types, e.g.:
public double averageStoreSales(quarter)
You need to say what type quarter
is, e.g.:
public double averageStoreSales(int quarter)
// -----------------------------^
Upvotes: 3