Source:
/*duo Ya fan*//*2015 9 23 */* for entering 4 integers and outputting 4 integers and/import java.util.*; public class Jisuan {public static void main (String args[]) {int count;//count used to denote the number of double next,sum; The next,sum is used to store the input 4 integers and 4 integers respectively. The sum=0;//initializes the sum. Scanner SC =new Scanner (system.in);//define a Scanner object, Scanner is a simple scanner that uses regular expressions to parse basic types and character types to read 4 numbers of input System.out.println ("Please enter 4 integers:"); for (count=0;count<4;count++)//{next=sc.nextint ();//The method that calls the class's Nextint () in a loop statement reads the number of inputs and places it in next Su m+=next;//adds each number of inputs to sum} System.out.println ("4 integers" and "+sum"); The sum output}}
Program Run Result:
Program Design ideas: First define a series of variables, count is used to represent the number of input integers, next is used to hold the input of each number, sum to hold 4 integers, and define a scanner object, Scanner is a simple text scanner that uses regular expressions to parse basic types and strings to read integers entered by the user. The Nextint () method of the class is called in the Recycle statement, the integer entered by the user is read, placed in next, and then added in sum, and finally 4 integers are evaluated through a loop.
Program Block diagram:
Program Block diagram:
Using Java to write a program to input 4 integers output 4 integers and