public static void Main (string[] args) {
Scanner input=new Scanner (system.in); Importing import java.util.Random is required;
Random a1=new random (); First pseudo-Random number object
Random a2=new random (); Second pseudo-Random number object
int bool=0;//Defining a computer--the first few questions
int true1=0;//definition How many answers?
int false1=0; The definition answers a few wrong questions
while (BOOL<10) {
System.out.println ("+ (bool+1) +" road title: ");
int One=a1.nextint (100); Receive random numbers, limit random numbers to less than 100
int Two=a2.nextint (100);//Receive random number, limit random number within 100
System.out.print (one+ "+" +two+ "=");
int Sum=input.nextint (); Receive input and/or import java.util.Scanner required; Package
Judge
if (sum== (one+two))
{
SYSTEM.OUT.PRINTLN ("Correct it!" ");
true1++; Calculator, answer right + 1 way
}else{
System.out.println ("wrong answer!") ");
false1++;//Calculator, answer wrong + 1 way
}
bool++;
}
SYSTEM.OUT.PRINTLN ("You answered correctly:" +true1+ "way, Answer wrong:" +false1);
}
How to use Java to achieve the 10-way addition summation, calculate the correct number of answers, answer the wrong number of ways!