ImportJava.util.*;ImportJava.util.Random; Public classSiZe {/** * @paramargs*/ Public Static voidMain (string[] args) {string[] str_1=NewString[] {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; String[] str_2=NewString[] {"+", "-", "*", "/"}; intindex = 0; intindex_1 = 0; intIndex_2 = 0; int[] A =New int[2]; Doubledata = 0; DoubleAnswer = 0; System.out.println ("Here are 20 simple arithmetic!" "); for(intk = 0; K < 20; k++) {System.out.print ("First" + (k+1) + "question:"); for(inti = 0; I < 2; i++) { intj = 0; Index_1=NewRandom (). Nextint (9); if(Str_2[index_2].equals ("/")) { while(I >= 2 && index_1 = = 0) {index_1=NewRandom (). Nextint (9); }} A[i]=index_1; System.out.print (Str_1[index_1]); if(I! = 1) {Index_2=NewRandom (). Nextint (4); System.out.print (Str_2[index_2]); }} System.out.println (); System.out.print ("Please enter the answer:"); Scanner input=NewScanner (system.in); Data=input.nextdouble (); Switch(index_2) { Case0: Answer= A[0] + a[1]; Break; Case1: Answer= a[0]-a[1]; Break; Case2: Answer= a[0] * a[1]; Break; Case3: Answer= (Double) A[0]/a[1]; Break; } if(Data = =answer) System.out.println ("You entered the correct answer!" "); ElseSystem.out.println ("The answer you entered is wrong!" "); System.out.println (); } }}
Arithmetic-upgrade version--1