Exercise03_10

 1 import java.util.Scanner;
 2 public class SubtractionQuiz {
 3     public static void main(String[] args){
 4         int number1=(int)(Math.random()*100);
 5         int number2=(int)(Math.random()*100);
 6         System.out.println("What is " + number1 + "+" + number2 + "? ");
 7         Scanner input=new Scanner(System.in);
 8         int answer=input.nextInt();
 9         if(answer==number1+number2){
10             System.out.println("You are correct!");
11         }
12         else{
13             System.out.println("You answer is wrong.");
14             System.out.println(number1 + "+" + number2 + " should be " + (number1+number2));
15         }
16     }
17 }

 

posted @ 2018-10-21 17:20  CHERRYL  阅读(177)  评论(0编辑  收藏  举报