This is a 300-way random arithmetic applet written by Java, with a range of 0~100 (excluding 100), and the result of the operation preserving two decimal places.
Program code:
ImportJava.util.*;classyunsuan{ Public Static voidMain (string[] args) {Random rand=NewRandom (); for(inti = 0; I < 300; i++){ intNUM1 = (int) (rand.nextdouble () * 100); intNum2 = (int) (rand.nextdouble () * 100); Doublenum3 = 0; CharCH = 0; Switch(Rand.nextint (4)){ Case0:ch = ' + '; NUM3 = 1.0 * NUM1 + num2; Break; Case1:ch = '-'; NUM3 = 1.0 * NUM1-NUM2; Break; Case2:ch = ' x '; NUM3 = 1.0 * NUM1 * NUM2; Break; Case3:ch = ' ÷ '; while (num2 = = 0) {num2 = (int) (rand.nextdouble () *);} num3 = 1.0 * NUM1/NUM2; Break; } num3*= 100; NUM3=Math.Round (NUM3); NUM3/= 100; if((Num3-(int) num3) = = 0) {System.out.println (Num1+ "" + ch + num2 + "=" + (int) num3); } Else{System.out.println (num1+ "" + ch + num2 + "=" +num3); } } }}
300-Way Random Arithmetic applet (written in Java)