// Tyler Rigsby, CSE 142 // Plays an addition game with the user where they must answer a series of addition problems, // earning one point per correct answer until they get two wrong answers // INCOMPLETE import java.util.*; public class AdditionGame { public static void main(String[] args) { System.out.println("Welcome to the CSE 142 Addition Game. We will ask"); System.out.println("a series of addition questions until you get 3 wrong."); System.out.println("Your score will be the number of questions you got right."); Random r = new Random(); Scanner console = new Scanner(System.in); int strikes = 0; int points = 0; while (strikes < 3) { playRound(r); } } // Plays a single round of the game, returning true if the user was correct and false otherwise public static boolean playRound(Random r, Scanner console) { // 2-5 int operands = r.nextInt(4) + 2; int value = r.nextInt(10) + 1; int sum = value; System.out.print(value); for (int i = 1; i < operands; i++) { // 1-10 value = r.nextInt(10) + 1; System.out.print(" + " + value); sum = sum + value; } System.out.print(" = "); int response = console.nextInt(); return response == sum; } }