import java.util.*;
class Demo{
public static void main(String[] args){
Random r = new Random();
Scanner sc = new Scanner(System.in);
while(true){
int i = r.nextInt(100);
int j = r.nextInt(100);
int op = r.nextInt(3);
int correctans = 0;
System.out.print(i);
if(op==0){
System.out.print("+");
correctans = i+j;
}
else if(op==1){
System.out.print("-");
correctans = i - j;
}
else if(op==2){
System.out.print("*");
correctans = i * j;
}
System.out.println(j+"=?");
int answer = sc.nextInt();
if(answer == correctans){
System.out.println("Correct Answer\n");
}
else{
System.out.println("Wrong Answer\n");
break;
}
}
}
}
class Demo{
public static void main(String[] args){
Random r = new Random();
Scanner sc = new Scanner(System.in);
while(true){
int i = r.nextInt(100);
int j = r.nextInt(100);
int op = r.nextInt(3);
int correctans = 0;
System.out.print(i);
if(op==0){
System.out.print("+");
correctans = i+j;
}
else if(op==1){
System.out.print("-");
correctans = i - j;
}
else if(op==2){
System.out.print("*");
correctans = i * j;
}
System.out.println(j+"=?");
int answer = sc.nextInt();
if(answer == correctans){
System.out.println("Correct Answer\n");
}
else{
System.out.println("Wrong Answer\n");
break;
}
}
}
}
No comments:
Post a Comment