此程序从命令行接收多个数字,求和之后输出结果

  1. 1.  设计思想、

a)  创建数组,for循环对数组遍历累加,输出结果。

 

  1. 2.  程序流程图、

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. 3.  源程序代码和结果截图

public class qwe {

 

      public static void main(String[] args) {

          

           int sum=0;

 

         System.out.println("numbers:"+args.length);

 

         for(String arg:args) {

 

               sum = sum + Integer.parseInt(arg);

 

          }

 

          System.out.println(sum);

 

      }

 

 

posted @ 2017-10-07 21:48  肥鹅PU火  阅读(230)  评论(1编辑  收藏  举报