Imitate the Javaapparguments.java example, write a program that receives multiple numbers from the command line, sums up the output, writes out its design idea, the program flowchart, the source program code.

Source: Internet
Author: User

a design idea

first , create a class in file and write the task name and class name (note the capitalization of the class name); The second step is the input of the parameter, and the sum variable is defined, and the third step is the requirement of the parameter data type, to convert the character type to an integer type and output (which is also the focus of this topic), This step is, of course, placed in the for loop of the input parameter, and finally the sum of the arguments and the output parameters.

two program flowchart

three source program code

Public class javaapparguments {

/**

* @param args

*/

Public Static void Main (string[] args) {

TODO auto-generated Method stub

System. out. println (" Number of parameters :"+args.length);// number of input parameters

int sum=0;

int i;

for (String Arg:args) {

I=integer. parseint              (ARG); Converting a parameter data type from a character type to an integer type

System.              out. println (ARG); Output Parameters

Sum=sum+i;

}

System.           out. println (" and for :"+sum); output parameter's and

}

}

Imitate the Javaapparguments.java example, write a program that receives multiple numbers from the command line, sums up the output, writes out its design idea, the program flowchart, the source program code.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.