java class content

   Java on the last lesson, dear Wang was the teacher gave us a vivid image of the theoretical and practical classes. At the beginning, the teacher starts with the myth of the Foolish Old Man tells the story of programming essence, is about the fundamental programming sequence, branching and looping. Java programs normally go through five stages: editing, compiling, loading, school inspection, execution. Also told us from the test to find the problem, find from inadequate testing, gave us a lot of basic questions and then tell the Java specification requirements for identifiers and identifiers, then define common data types Java constants, and the new feature that allows a plurality of spaced underlined digits, then the original data type and the addition type int, float and a few types, the rest are used to reference the object, the following are enumerated type enum size, it can be used to enumerate the switch statement, then talk about the Java arithmetic operators and its priority. Followed by conversion between variable types and memory usage rule variables and scope of variables, and to distinguish between the original reference type variable type, how the string into a float. The last two classes the teacher let us conduct a self-test, the content is: on the second grade, a software company programmers child two columns, teachers give parents a 30 four day operations subject to the elementary-school children. 2-post immediately thought of writing a small program to do it. Then add some small in claim 1, subject to avoid duplication; 2, can be customized (number / printing mode); 3, can control the following parameters: Does multiplication and division, whether parentheses, a numerical range, presence or absence of the complex subtraction, division has no remainder, such as whether to support scores. The following is my program

import java.util.Random;
import java.util.Scanner;
public class suanshu {
 static Scanner sc = null;
 static String a3=new String("   ");
 public static int s1 = new Random().nextInt(100);
 public static int s2 = new Random().nextInt(100);
 public static int s3 = new Random().nextInt(100);
 public static int a[][]=new int[100000][2] ;
 public static int s[]=new int[100000];
 public static void main(String[] args) {
  sc = new Scanner(System.in);
  System.out.println("请输入题数:");
  int n=sc.nextInt();
  System.out.println("请输入每行的题数:");
  int m=sc.nextInt();
  for(int i=0;i<n;i++) {
   if((i)%m==0)
    System.out.print("\n");
   System.out.print((i+1)+":");
   s1 = new Random().nextInt(100);
   System.out.print(s1);
   s2 = new Random().nextInt(100);
   s3 = new Random().nextInt(100);
   //重复
   
   a[i][0]=s1;
   a[i][1]=s3;
   s[i]=s2;
   
   for(int j=0;j<i;j++) {
    if(a[j][0]==s1&&a[j][1]==s3&&s[j]==s2) {
     s3 = new Random().nextInt(100);
     while(s3==a[i][1]) {
      s3 = new Random().nextInt(100);
    }
    s3 = new Random().nextInt(100);
    while(s3==a[i][1]) {
     
    }
   }}
   if(s2%4==0)
    System.out.print("+");
   if(s2%4==1) {
    System.out.print("-");
    
     while(s1<s3) {
      s3 = new Random().nextInt(100);
     }
    
   }
    
   if(s2%4==2) {
    System.out.print("*");
    while(s1*s3>=100) {
     //s1 = new Random().nextInt(100);
     s3 = new Random().nextInt(100);
    }
   }
    
   if(s2%4==3) {
    System.out.print("/");
    while(s3!=0&&s1/s3!=0){
     //s1 = new Random().nextInt(100);
     s3 = new Random().nextInt(100);
    }
   }
    
   
   System.out.print(s3);
   System.out.print("=");
   
   System.out.print(a3);
  }
  
 
 }
 
 
}

The above is the general content of the last class of Java

Guess you like

Origin www.cnblogs.com/hanyong123/p/11573075.html