The Java implementation receives multiple numbers from the command line and outputs the results after summing.
1 Design ideas:
(1) Create a class.
(2) The number of output parameters.
(3) defines the NUM and sum of int, which is used to store the sum of parameters and parameters respectively.
(4) A For loop argument is coerced into an int, and the converted parameter and sum are added, and the final result is recorded with Sum.
(5) Output sum.
2 Program Flowchart:
3 Source code:
Package CSXJ;
public class Csxj {
public static void Main (string[] args)
{
System.out.println ("Number of parameters" +args.length);
int num;//parameters that store integer types
int sum=0;//parameter's and
for (String Arg:args)//Loop
{
Num=integer.parseint (ARG);//cast string argument to int type
Sum=sum+num;
}
System.out.println ("Several numbers combined with" +sum);//Output
}
}
4 results:
Input parameters:
Operation Result:
The
receives multiple numbers from the command line with the Java implementation and outputs the results after summing.