| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 219 人关注过本帖
标题:Jcreator Array错误
只看楼主 加入收藏
southnorth
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-6-9
收藏
 问题点数:0 回复次数:0 
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
搜索更多相关主题的帖子: Array Jcreator 
2010-06-09 14:59
快速回复:Jcreator Array错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020173 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved