NumberGame Class************ import javax.swing.*; import java.util.*; /** * This class.... * * @author Bill Kukowski */ class NumberGame { /** * Main method. * * @params args */ public static void main(String[] args) { boolean playAgain = true; while (playAgain) { int seconds = Integer.parseInt(JOptionPane.showInputDialog(null, "How many seconds do you want to complete each problem? (Default 30)", 30)); Problems problems = new Problems(); Scanner scanner = new Scanner(System.in); String guess; float guessF; long startTime, answerTime; boolean correctAns, underTime; int[] scores = new int[4]; for (int p=0;p<10;p++) { guess = ""; startTime = System.currentTimeMillis(); System.out.println(problems.getNumerator1(p) + " " + problems.getNumerator2(p)); System.out.println("─" + " " + problems.getOperation(p) + " " + "─"); System.out.println(problems.getDenominator1(p) + " " + problems.getDenominator2(p)); System.out.println("You have " + seconds + " seconds remaining. Enter answer as a fraction (e.g. 4/7)"); guess = scanner.next(); String[] components = guess.split("/"); guessF = (float) Integer.parseInt(components[0]) / (float) Integer.parseInt(components [1]); answerTime = System.currentTimeMillis(); correctAns = guessF == problems.getAnswer(p); underTime = answerTime < startTime + (seconds * 1000); if ( correctAns && underTime) scores[0]++; if ( correctAns && !underTime) scores[1]++; if ( !correctAns && underTime) scores[2]++; if ( !correctAns && !underTime) scores[3]++; System.out.println(""); System.out.println("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); System.out.println(""); System.out.println(problems.getAnswer(p)); System.out.println(guessF); System.out.println(Arrays.toString(scores)); } int points = (10 * scores[0]) + (6 * scores[1]) + (3 * scores[2]); System.out.println(""); System.out.println(""); System.out.println(""); System.out.println("********You're Finished!********"); System.out.println(""); System.out.println(" Under Over"); System.out.println(" Time Limit Time Limit"); System.out.println(""); System.out.println("Correct Answers " + scores[0] + " " + scores[1]); System.out.println("Wrong Answers " + scores[2] + " " + scores[3]); System.out.println("Total Points: " + points + "(" + (scores[0] * 10) + " + " + (scores[1] * 6) + " + " + (scores[2] * 3) + " + 0"); System.out.println("Do you want to play again? 1 for yes 0 for no."); if (!(scanner.nextInt() == 1)) { playAgain = false; } } } } Problems Class********* /** * This class.... * * @author Bill Kukowski */ class Problems { private int[][] fractionGroup1 = new int[2][10]; private int[][] fractionGroup2 = new int[2][10]; private int[] operations = new int[10]; private float[] answers = new float[10]; private float tmpNum1 = 0; private float tmpNum2 = 0; public Problems() { //generates first array of fractions for (int r=0;r<2;r++) { for (int c=0;c