日期:2014-05-20  浏览次数:20757 次

商品输入问题
import   java.util.Scanner;
public   class   Quo
  {   public   static   void   main(String   args[])
      {   int   m,n;
          double   q=0.00;  
          double   w=0.00;  
          double   e=0.00;  
          double   r=0.00;  
          double   t=0.00;  
          double   salary=0.00;
          double   values;
        Scanner   input=new   Scanner(System.in);
          do
        {       System.out.print( "input   the   number   of   the   product: ");
                n=input.nextInt();
                System.out.print( "input   the   quantity   of   the   product: ");
                  m=input.nextInt();
                switch(n)
              {   case   1:values=300.00;q=m*values*0.9;break;
                    case   2:values=200.00;w=m*values*0.9;break;
                    case   3:values=100.00;e=m*values*0.9;break;
                  case   4:values=50.00;r=m*values*0.9;break;
           
                }
          }while(n!=0);
      t=salary+q+w+e+r;
    System.out.printf( "the   salary   of   the   employee   is   %f ",t);
          }
}
这个程序的大概意思就是输入   销售出商品号和商品数目,然后计算员工的总工资,我是想把它改写成还有循环输入员工的号码然后再输入这些信息。就是要计算多个员工的工资。。。怎么样改呢?

------解决方案--------------------
命令行输入,感觉回到了c时代,呵呵