/* 我想创建一个二维数组,它将接受 6 个部门的 4 个季度的输入。例如 - “输入第一部门的第一季度销售额”。我写了这段代码,但是我无法让我的案例语句在我的“GetMessage”方法中工作。*/
import java.util.*;
public class EnumQuarter
{
static final int quarter;
static final int First;
static final int Second;
static final int Third;
static final int Forth;
public class Quarterly
{
private final int ROW = 6;
private final int COL = 4;
private Scanner _scanner;
Scanner keyboard = new Scanner(System.in);
public Quarterly(Scanner scanner)
{
Scanner keyboard = new Scanner(System.in);
this._scanner = scanner;
}
/* I am getting a compiling error here, it says that a constant expression is required
for every case statement for example " case EnumQuarter.First:" This gives me that
compiling error. Am I missing some syntax? or am I doing something completely wrong here . */
private String GetMessage(int quarter, int departmentNumber)
{
switch(quarter)
{
case EnumQuarter.First:
return "Enter The First Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case EnumQuarter.Second:
return "Enter a The Second Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case EnumQuarter.Third:
return "Enter a The Third Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
case EnumQuarter.Forth:
return "Enter a The Forth Quarterly Sales For Department [ " + departmentNumber+" ]. . . . . $ ";
}
}
/* I have not gotten to run this class yet but since I am new to java, I wonder if I
am creating my 2-D array properly. Please take a look at it and comment me giving me
advise on weather I am doing it properly or if there is a better way of doing it */
public double GetTotalForDepartments(EnumQuarter quarter)
{
double [][] sales = new double [ROW][COL];
int num = 1;
double total = 0;
for (int row = 0; row < ROW ; row++)
{
// This for statement is taking the column from the array in order to fill with input
for (int col = 0; col < COL; col++)
{
// This will receive sale numbers from the six departments
System.out.print(message + "[" + num + " ]. . . . . $ ");
sales[row][col] = scanner.nextDouble();
num++;
// This for statement will sum each department's input
for (int i = 0; i < sales.length; i++);
total += sales[row][col];
}
}
return total;
}
}
}