Design ideas: Get the number of inputs, deposit a new dynamic array, and then convert the number in the dynamic array from string to int using the Integer.parseint () function to add the output.
Program Flowchart: Get the number of inputs---New dynamic array, enter the number of inputs into a dynamic array, and establish an int variable s=0-> using the Integer.parseint () function to convert and add the output;
SOURCE program code:
Import java.util.ArrayList;
public class D1
{
@SuppressWarnings ({"Unchecked", "Rawtypes"})
public static void Main (string[] args)
{
int A;
a=args.length;//get the number of inputs
ArrayList a1=new//Creating dynamic arrays
ArrayList (); for (int i=0;i<a;i++)//To deposit the entered number into a dynamic array
A1.add (Args[i]);
int s=0;
for (int i = 0;i<a;i++)
{
String b= (String) a1.get (i);
int C;
C=integer.parseint (b);//convert string to int type
s=s+c;//Add sum
}
System.out.println (s);//Output
}
}
Program:
The program receives multiple numbers from the command line and outputs the results after summing.