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");
}
}
}
III. realization of the results
Iv. Analysis of reasons why classes cannot be made
first, because forget how to use the random number so that all the attention to this, can not consider the whole problem.
Summary is not often due to their own programming, because of their laziness, the study of the lack of knowledge forgotten. I should strengthen myself into training later.
Second, is sloppy, do not see the topic, the topic directly to realize arithmetic to seek results
In short, the current poor programming ability, the future must improve
Code implementation for arithmetic problems that produce fractions or integers randomly