Advertisement
apez1

Term 1: Lesson 13 - Coding Activity 5

Sep 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1.  
  2.  
  3.     import java.io.*;
  4. import static java.lang.System.*;
  5. import java.util.Scanner;
  6. import java.lang.Math;
  7.  
  8. public class Lesson_13_Activity_Five {
  9.       public static void main (String str []) throws IOException {
  10.       Scanner scanner = new Scanner(System.in);
  11.       double x;
  12.       double y;
  13.       double z;
  14.       double a;
  15.      
  16.       x = (int)(Math.random() * (12) + 1);
  17.       y = (int)(Math.random() * (12) + 1);
  18.      
  19.       a = (int)(x * y);
  20.      
  21.       System.out.println(x + " * " + y);
  22.       System.out.println("What is the answer?");
  23.       z = scanner.nextDouble();
  24.      
  25.       if(a == z){
  26.           System.out.println("Correct!");
  27.           }
  28.      else{
  29.          System.out.println("Wrong");
  30.      }
  31.        
  32.       }
  33.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement