1 /*2 requirements: 30 arithmetic per day for pupils to do3 */4 5 classRand6 {7 Public Static voidsop (Object obj)8 {9 System.out.println (obj);Ten } One Public Static voidMain (string[] args) A { -SOP ("Elementary school students work after the second year, 30 arithmetic daily Practice:"); - the intCount = 0; - - for(inti=0;i<30; i++ ) - { + intD1 = (int) ((Math.random ()) *100); - intD2 = (int) ((Math.random ()) *100); + intK = (int) ((Math.random ()) *100); A intK2 = (int) ((Math.random ()) *100); at intK3 = (int) ((Math.random ()) *100); - intK4 = (int) ((Math.random ()) *100); - intx = 1; - if(0<=k&&k<12) -x = 1; - Else if(12<=k&&k<24) inx = 2; - Else if(24<=k&&k<36) tox = 3; + Else if(36<=k&&k<48) -x = 4; the Else if(48<=k&&k<60) *x = 5; $ Else if(60<=k&&k<72)Panax Notoginsengx = 6; - Else if(72<=k&&k<84) thex = 7; + Else Ax = 8; the Switch(x) + { - Case1: $SOP (d1+ "+" +d2+ "="); $ Break; - Case2: - Jianfa (D1,D2); the Break; - Case3:WuyiSOP (d1+ "*" +d2+ "="); the Break; - Case4: Wu Chufa (D1,D2); - Break; About $ - Case5: -SOP (Zhenfenshu (K,K2) + "+" +zhenfenshu (K3,K4) + "="); - Break; A Case6: +SOP (Zhenfenshu (K,K2) + "-" +zhenfenshu (K3,K4) + "="); the Break; - Case7: $SOP (Zhenfenshu (K,K2) + "*" +zhenfenshu (K3,K4) + "="); the Break; the Case8: theSOP (Zhenfenshu (K,K2) + "/" +zhenfenshu (K3,K4) + "="); the Break; - default: inSOP ("Duang,duang,daung"); the Break; the } Aboutcount++; the } the theSOP ("All Above:" +count+ "problem. "); + - } the Public Static voidJIANFA (intAintb//because the second grade of primary school did not learn negative numbers, so subtraction can not be negativeBayi { the if(a>=b) theSOP (A + "-" +b+ "="); - Else - { theSOP (b + "-" +a+ "="); the } the the } - the Public Static voidChufa (intAintb//to make the division meaningful, the divisor cannot be zero, the { the if(b>0) 94SOP (A + "/" +b+ "="); the //if the divisor is zero, it is added 10, and then the Operation the Else the {98B = B + 10; AboutSOP (A + "/" +b+ "="); - }101 102 }103 Public StaticString Zhenfenshu (intAintb)104 { the if(a<=b)106 returnA + "/" +b;107 Else108 returnB + "/" +A;109 } the }111 /* the Summary:113 Overall idea: the first to see this topic, the 1. Generate a random number of two or two bits, the 2, then randomly generates an operation symbol in the arithmetic, the 3, the combination, output. 117 4, you can perform the operation of the true fraction. 118 119 problems encountered: - 1. At first, forgetting the method of generating random numbers in the Java language, it took a little time in the classroom121 Read the Java API and know that the random number generation is math.random ()122 2, then the random generation of operational symbols after thinking: You can generate 0~99 random number, divided into four parts,123 control with a switch statement. 124 3, the next solution to the two number subtraction, the case of negative: let two exchange a bit OK. the 4, finally solved the division operation divisor can not be zero, if the divisor is zero, it is added 10, and then the Operation126 5, add the operation of the true fraction, through the intersection of integer and true score display. 127 - */
30 arithmetic topics per day in class practice