import java.util.Random; import java.util.Scanner; public class math { public static void main(String[] args) { String[] operate=new String[]{"+","-","×","÷"}; int[] numbers=new int[100]; int x,y,f; int z = 0; int j=0,k=0; String b; for(int i=1;i<=100;i++){ numbers[i-1]=i; } Random r=new Random(); for(int i=1;i<101;i++){ System.out.println(i); System.out.println("答对"+j+"答错"+k+"未答"+(100-j-k)); x=numbers[r.nextInt(100)]; y=numbers[r.nextInt(100)]; b=operate[r.nextInt(4)]; if(x<y){ f=x; x=y; y=f; } if(b==operate[0]){ z=x+y; } if(b==operate[2]){ z=x*y; } if(b==operate[1]){ z=x-y; } if(b==operate[3]){ z=x/y; } System.out.println(x+b+y+"="); @SuppressWarnings("resource") Scanner scanner = new Scanner(System.in); double t = scanner.nextInt(); if(t==z){ System.out.println("答案正确"); j++; } else{ System.out.println("答案错误,正确为"+z); k++; } System.out.println(" **************** "); } } }