Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class AddingGame
- {
- public static void main(String[] args)
- {
- int incorrect = 0;
- Random number = new Random();
- Scanner pikachu = new Scanner(System.in);
- int right = 0;
- while(incorrect < 3)
- {
- int answer = 0;
- for(int count = 1; count<=number.nextInt(5 - 2 + 1) + 2; count++)
- {
- int question = number.nextInt(100);
- System.out.print(question + "+");
- answer = answer + question;
- }
- System.out.print("0 = ");
- int yourAnswer = pikachu.nextInt();
- if(yourAnswer != answer)
- {
- System.out.println("Wrong! The correct answer was: " + answer);
- incorrect ++;
- }
- else
- {
- right ++;
- }
- }
- System.out.println("You got " + right + " correct! Good job! Thanks for playing!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement