First, design ideas:
1, understand the requirements of the topic, that is, to write a program to complete the addition of multiple numbers and output results, the problem is the command line parameter is a string, need to be converted into a number after the calculation, by querying the internet to solve the problem method, with "*.nextint ()" function can solve the issue.
2, the structure of the design program, the first to apply for dynamic space, to complete the requirements to enter multiple numbers. Finally, the program is completed by inputting, calculating and outputting.
Second, the Process flow chart
Third, the source code
Package Sum;import Java.util.Scanner; Public classText { Public Static voidMain (string[] args) {Scanner scan=NewScanner (System.inch);//creating a Scanner class object intN; System. out. println ("Please enter a few numbers to sum:"); N= Scan.nextint ();//Enter the number of required and Double[] numarray; Numarray=New Double[n];//define n variable of type doubleSystem. out. Print ("Please enter"+N); System. out. println ("a number to calculate:"); for(inti =0; i<numarray.length;i++) {Numarray[i]= Scan.nextint ();//Enter the n numbers to be computed}//converts the input string to a floating-point type Doublesum =0; for(inti =0; i<numarray.length;i++) {sum+=Numarray[i]; }//calculation of the number of inputs andSystem. out. println ("The and of these several numbers are:"+sum);//Output Calculation Results }}
Iv. Results
Java Multiple number addition source code flowchart design Idea