Experimental requirements: Write a piece of code, execute the result output 30 arithmetic topic, consider the level of second grade students in primary school
Experiment idea: Use random method to generate the stochastic number, define each number range; Select an operator randomly with switch and edit the output order of the number and symbol
The code is as follows:
Import java.util.*;
public class Test {
public static void Main (string[] args) {
TODO auto-generated Method Stub
for (int i = 0; i <; i++) {
Random r = new Random ();
int a = r.nextint (100);
int b = r.nextint (100);
int c = R.nextint (4);
char d = ';
Switch (c) {
Case 0:
d = ' + ';
Break
Case 1:
d = '-';
Break
Case 2:
d = ' x ';
Break
Case 3:
d = ' ÷ ';
if (b==0) {
i--;
Continue
}
Break
Default
d = ';
}
SYSTEM.OUT.PRINTLN (i + 1 + "." + A + D + b);
}
}
}
2015/3/6 Introduction to Software engineering classroom operations