% String message = request.getParameter("message"), n1 = request.getParameter("n1"), n2 = request.getParameter("n2"), correct = request.getParameter("correct"), total = request.getParameter("total"), answer = request.getParameter("answer"); if (message != null) { try { if (Integer.parseInt(answer) == Integer.parseInt(n1) + Integer.parseInt(n2)) { correct = "" + (Integer.parseInt(correct) + 1); message = "Good answer."; } else { message = "Your answer was wrong."; } total = "" + (Integer.parseInt(total) + 1); message += " Score now: " + correct + " out of " + total; n1 = "" + (int) (Math.random() * 100 - 50); n2 = "" + (int) (Math.random() * 100 - 50); } catch (Exception e) { // out.println(e.toString()); message = e.toString() + "Score now: " + correct + " out of " + total; } } else { message = "Welcome to the game!"; correct = "0"; total = "0"; n1 = "" + (int) (Math.random() * 100 - 50); n2 = "" + (int) (Math.random() * 100 - 50); } %>