A holistic approach to Java summation

Source: Internet
Author: User

first, Design Ideas:

Design This program we need to take into account the input parameters, and can enter multiple parameters, and for the user to consider the various boundary problems. first, we should give the input parameter statement so that the user can enter it. In the second step, we should output the number of parameters, see if the input parameters, if the parameter is 0, prompting the user to enter a parameter of 0, and then the output of the number of parameters output to the User. The third step is to force the conversion of its arguments with the int type, and then add them with a for loop. The final step is to output the resulting results.

Three: Source Code

Multiple parameter summation problems

zhanxinwu, September 26th,2016.

public class Javaapparguments {

/**

* @param args

*/

public static void main (string[] Args) {

System.out.println ("number of parameters" +args.length);

int sum=0;

For (String Arg:args)

{

Sum=sum+integer.parseint (arg);

}

System.out.println (sum);

}

}

A holistic approach to Java summation

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.