I. Design ideas
1. Create the project sum, add the class sum under Package Add, and the function is the sum of the integers.
2. Enter multiple integers.
3. Convert the input string to a number, import the package java.util with the import statement, and then call the class scanner
4. For sum initialization, add sums to multiple integers.
5. Outputs the sum result of multiple integers.
Two. Flowchart
Three. Source code
Package Add;
Import Java.util.Scanner;
public class Sum {
public static void Main (string[] args) {
String s;
Scanner sc=new Scanner (system.in);
SYSTEM.OUT.PRINTLN ("Please input three integers:\n");
int sum=0; Sum initialization
for (int i=0;i<3;i++) {
S=sc.next ();
int Parameter=integer.parseint (s); Convert a parameter in a string to an integer type
Sum+=parameter; Summation sum for each number of inputs
}
System.out.println ("The sum is:" +sum);
}
}
Four. Results
java-integer addition sum