[0703] job guessing game

. 1  Package com.workprojects;
 2  / ** 
. 3  * guessing game
 4  * Number of columns: 8,4,2,1,23,344,12
 5  * cycle of the output value of the number of columns, the number of required values and all the column
 6  * from any keyboard a data input, determines whether the number of columns contained in the frequency
 . 7  * 2019-07-03
 . 8  * @author L
 . 9   * / 
10  
. 11  Import java.util.Scanner;
 12 is  
13 is  public  class Work070301 {
 14      static Scanner SC = new new Scanner (the System. in);
 15      public  static  void main (String [] args) {
 16          int[] = the nums new new  int [] {} 8,4,2,1,23,344,12; // number of columns of values 
. 17          System.out.println ( "guessing game ----- -----" ) ;
 18          System.out.print ( "Please enter the numbers you guess:" );
 19          int NUM = sc.nextInt (); // input digital guess 
20          int sUM = 0; // number of columns in the sum of 
21          boolean Flag = false ; // Analyzing 
22 is          for ( int I = 0; I <nums.length; I ++ ) {
 23 is              IF (== NUM the nums [I]) {
 24                  In Flag = to true ;
25              }
 26 is          }
 27          System.out.println ( "The numbers contained in the game is:" );
 28          for ( int num1: the nums) {
 29              SUM + = num1;
 30              of System.out.print (num1 + "\ T" );
 31 is          }
 32          IF (In Flag) {
 33 is              System.out.println ();
 34 is              System.out.println ( "*** Congratulations, you guessed ***!" );
 35          } the else {
 36              the System. out.println ();
 37              System.out.println ( "*** Unfortunately, you guess wrong ***!");
 38 is          }
 39          System.out.println ( "The game is the sum of all values:" + SUM);
 40      }
 41 is }

 

Guess you like

Origin www.cnblogs.com/yanglanlan/p/11134031.html