import java.util.Scanner; public class example { public static void main(String[] args) { int number1 = (int) (Math.random() * 10); int number2 = (int) (Math.random() * 10); System.out.println("What is " +number1 + " * " + number2 + "?"); Scanner scanner = new Scanner(System.in); int answer = scanner.nextInt(); if(number1 * number2 ==answer) System.out.println("You are correct"); else System.out.println("your answer is Wrong\n" +number1 + " * " + number2 + " should be " + (number1 * number2)); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter