Program Design Ideas:
After visiting Baidu and other websites, I learned to convert the string s to an integer usable integer.parseint (s), so I knew how to translate the characters into integers. Enter multiple integers by a[i]=integer.parseint (Args[i]). Defines an array to receive numbers converted from characters, and finally sums them with a for loop.
Flow chart:
Program code:
public class add{
public static void Main (String args[]) {
int i,sum=0;
String c= "parameters are:";
String b= "sum is:";
Int[] A=new int[20];
System.out.println ("Number of parameters:" +args.length);
System.out.println (c);
for (String Arg:args) {
System.out.println (ARG);
}
for (i=0;i<args.length;i++) {
A[i]=integer.parseint (Args[i]);
Sum=sum+a[i];
}
System.out.println (b+sum);
}
}
Program:
Enter a few numbers at the command prompt, sum (flow chart I was sent in the form of a picture)