PackageYun;ImportJava.util.Random;ImportJava.util.*; Public classNumber {/*** Fan Mingxiang * Function: A simple arithmetic generation system for elementary school students*/ Public Static voidMain (string[] args) {intMax=4; intMin=1; Random Random=NewRandom (); //System.out.println (s); Booleanpan=true; Do { ints = random.nextint (max)% (max-min+1) +min; Scanner in=NewScanner (system.in); System.out.println ("Please enter the first number of a arithmetic:"); Doublex=in.nextdouble (); System.out.println ("Please enter the second number of a arithmetic:"); Doubley=in.nextdouble (); Switch(s) { Case1: {System.out.println (x+ "+" +y+ "=" ); Doublexy=in.nextdouble (); if(xy==x+y) {System.out.println ("You did the right thing!! "); } if(xy!=x+y) {System.out.println ("You did it wrong!! "); } Break; } Case2: {System.out.println (x+ "-" +y+ "=" ); Doublexy=in.nextdouble (); if(xy==x-y) {System.out.println ("You did the right thing!! "); } if(xy!=x-y) {System.out.println ("You did it wrong!! "); } Break; } Case3: {System.out.println (x+ "*" +y+ "=" ); Doublexy=in.nextdouble (); if(xy==x*y) {System.out.println ("You did the right thing!! "); } if(xy!=x*y) {System.out.println ("You did it wrong!! "); } Break; } Case4: {System.out.println (x+ "/" +y+ "=" ); Doublexy=in.nextdouble (); if(xy==x/y) {System.out.println ("You did the right thing!! "); } if(xy!=x/y) {System.out.println ("You did it wrong!! "); } Break; } } } while(pan=true); }
}
Elementary School Arithmetic