StefanTobler

Lesson 13 Activity 5

Sep 25th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. /*
  2.  * Lesson 13 Coding Activity 5
  3.  * Create a program to let the user practice their multiplication tables.
  4.  * Print two random integers between 1 and 12 each on a new line.
  5.  * Then, ask the user to input the multiplication of the two numbers.
  6.  * If they enter the correct product print "Correct!" otherwise print "Wrong".
  7.  */
  8.  
  9.  
  10. import java.util.Scanner;
  11.  
  12. class Lesson_13_Activity_Five {
  13.     public static void main(String[] args)
  14.      {
  15.        Scanner scan = new Scanner(System.in);
  16.        
  17.        int a = (int) (Math.random()*12 + 1);
  18.        int b = (int) (Math.random()*12 + 1);
  19.        
  20.        System.out.println(a + " " + b + "\n Input what the product of these two numbers is:");
  21.        
  22.        int x = scan.nextInt();
  23.        
  24.        if(x == (a*b))
  25.        {  
  26.          System.out.println("Correct!");
  27.        }
  28.        else
  29.        {
  30.          System.out.println("Wrong");
  31.        }
  32.     }
  33. }
Add Comment
Please, Sign In to add comment