A design idea:
First, complete how to achieve a random two numbers and a arithmetic symbol
Second, how to realize the output in the form of arithmetic problem
Iii. How to achieve the selective output how many questions
Four, how to add the function of the output score
Second, the Code implementation
Package com.minirisoft;
Import java.util.*;
public class Yunsuan {
public static void Main (string[] args) {
Scanner input=new Scanner (system.in);
System.out.println ("Please enter the question of whether you want to output a fractional question or an integer arithmetic title: 0: Score, 1: integer");
int A=input.nextint ();
Switch (a) {
Case 0:
{
SYSTEM.OUT.PRINTLN ("You have selected a score please enter how many arithmetic questions to output");
int J=input.nextint ();
Random t=new random ();
Char arr[] = {' + ', '-', ' * ', '/'};
for (int i=0;i<j;i++) {
System.out.print (T.nextint (+) + "/" + (T.nextint (30) +1) + "");
System.out.print (Arr[t.nextint (4)]);
System.out.println ("+t.nextint (+) +"/"+ (T.nextint (30) +1) +" = ");
}
Break
}
Case 1:
{
SYSTEM.OUT.PRINTLN ("You have selected an integer, please enter how many arithmetic questions to output");
int J=input.nextint ();
Random t=new random ();
Char arr[] = {' + ', '-', ' * ', '/'};
for (int i=0;i<j;i++) {
System.out.print (T.nextint (30));
System.out.print (Arr[t.nextint (4)]);
System.out.println (T.nextint (30) +1+ "=");
}
Break
}
Default:System.out.println ("The number entered is incorrect, please enter 0 or 1");
}
}
}
Third, the experimental results
Four reasons why you can't make a class
First, because forget how to use the random number so that all the attention in this, can not consider the whole problem.
Summary is not often due to their own programming, because of their laziness, the knowledge of the lack of learning forgotten, and later should practice more programming.
Second, a bit sloppy, do not look at the topic, directly to the problem to realize arithmetic to seek results
In short, the current poor programming ability, the future must be more practice.
Code implementation for arithmetic of randomly generated fractions or integers