Guest User

Untitled

a guest
Oct 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class testClass
  4. {
  5. public static void main (String[] args)
  6. {
  7. int num1 = (int) (Math.random() * (500));
  8. int num2 = (int) (Math.random() * (500));
  9.  
  10. System.out.println("What's "+num1+" + "+num2+"?");
  11.  
  12. while(true)
  13. {
  14. Scanner scan = new Scanner(System.in);
  15. int input = scan.nextInt();
  16.  
  17. if (input==(num1+num2))
  18. {
  19. System.out.print("Correct answer!");
  20. break;
  21. }
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment