Jcreator Array错误
public class FastFoodMenu//class name here, same as file name{
public FastFoodMenu()throws IOException{//constructor, place class name here
// use BufferedReader class to input from the keyboard
// declare a variable of type BufferedReader
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
//declare variable for input
String inputString;
welcome();
Order();
finishUp();
}//end constructor
public void welcome()
{System.out.println("Welcome to X restaurant!");//warm up customers
return;}
public void finishUp()
{System.out.println("Thank you for your order. Please go next window to pay your order and take your food.");
return;}// end the ordering
public void Order(){//local variables
int qty[]=new int[3];
qty[0]=0;
qty[1]=0;
qty[2]=0;
//double[] price={7.5,5,3.75};
double price[]=new double[3];
price[0]=7.5;
price[1]=5;
price[2]=3.75;
String[] product={"Hot Dogs","Fries","Lemonade"};
double taxRate = 0.07;
double tax;
double subtotal;
double total;
Qty();
subtotal=preTotal();
tax=calTax(taxRate,subtotal);
total=subtotal+tax;
printBill(tax,total);
return;}
public void Qty(){
int choice;
int qty[]=new int[3];
do
{choice=selection();
switch(choice)
{ case 1: qty[(choice-1)]=qty[(choice-1)]+1;
break;
case 2: qty[(choice-1)]=qty[(choice-1)]+1;
break;
case 3: qty[(choice-1)]=qty[(choice-1)]+1;
break;
case 4: System.out.println("Quitting");
break;
default: System.out.println("Must select 1 through 4.");
break;
}} while(choice!=4);
return;}
public double preTotal()
{int count=0;
double total=0;
while(count<3){
total=total+qty[count]*price[count];
count++;}
return total;}
public int selection()
{int count=0;
int select;
while(count<3)
{System.out.println("("+count+") "+product[count]);}
System.out.println("(4) End Ordering");
select=Integer.parseInt(input.readLine());
return select;}
public double calTax(double taxRate, double subtotal){
double taxAmt;
taxAmt=taxRate*subtotal;
return taxAMt;}
public void printBill(double tax,double total)
{int count=0;
System.out.println("Product Quantity Cost");
while (count<3)
{ if (qty[count]!=0)
{System.out.println(product[count]+" "+qty[count]+" "+price[count]);}
count++;}
System.out.println("Tax (7%) "+tax);
System.out.println("Total "+total);
return;}
public static void main(String [] args) throws IOException // main method
{
new FastFoodMenu(); //class constructor name
} // end the main method
}// end the program