When it gets to the end, its supposed to ask the user if they want to play again, 1 for yes and 2 for no, it plays again regardless of what you want to do?
import javax.swing.JOptionPane; import java.util.Random; public class Lab6 { public static void main(String args[]) { int probType, lvl; int opAnd1 = 0, opAnd2 = 0, cAwnser, sAwnser; int correctA; boolean pAgain; int tempBoo; Random rndm = new Random(); do { String s1 = JOptionPane.showInputDialog("Enter problem type: "); probType = Integer.parseInt(s1); while (probType < 0 || probType > 5) { s1 = JOptionPane.showInputDialog("Invalid number, please try again: "); probType = Integer.parseInt(s1); } s1 = JOptionPane.showInputDialog("Enter desired level: "); lvl = Integer.parseInt(s1); while (lvl < 0 || lvl > 3) { s1 = JOptionPane.showInputDialog("Invalid number, please try again: "); lvl = Integer.parseInt(s1); } correctA = 0; for(int i = 1; i <= 10; i++) { switch (lvl) { case 1: opAnd1 = rndm.nextInt(10); opAnd2 = rndm.nextInt(10); break; case 2: opAnd1 = rndm.nextInt(100); opAnd2 = rndm.nextInt(100); break; } switch (probType) { case 1: cAwnser = opAnd1 + opAnd2; JOptionPane.showMessageDialog(null,(opAnd1 + " + " + opAnd2)); s1 = JOptionPane.showInputDialog("What is your awnser: "); sAwnser = Integer.parseInt(s1); if (cAwnser == sAwnser) { JOptionPane.showMessageDialog(null,"Good Job!"); correctA++; } else { JOptionPane.showMessageDialog(null,"Better luck next time!"); } break; case 2: cAwnser = opAnd1 - opAnd2; JOptionPane.showMessageDialog(null,(opAnd1 + " - " + opAnd2)); s1 = JOptionPane.showInputDialog("What is your awnser: "); sAwnser = Integer.parseInt(s1); if (cAwnser == sAwnser) { JOptionPane.showMessageDialog(null,"Fantastic!"); correctA++; } else { JOptionPane.showMessageDialog(null,"Nice Try!"); } break; case 3: cAwnser = opAnd1 * opAnd2; JOptionPane.showMessageDialog(null,(opAnd1 + " * " + opAnd2)); s1 = JOptionPane.showInputDialog("What is your awnser: "); sAwnser = Integer.parseInt(s1); if (cAwnser == sAwnser) { JOptionPane.showMessageDialog(null,"Terrific!"); correctA++; } else { JOptionPane.showMessageDialog(null,"So Close!"); } break; case 4: cAwnser = opAnd1 / opAnd2; JOptionPane.showMessageDialog(null,(opAnd1 + " / " + opAnd2)); s1 = JOptionPane.showInputDialog("What is your awnser: "); sAwnser = Integer.parseInt(s1); if (cAwnser == sAwnser) { JOptionPane.showMessageDialog(null,"Sensational!"); correctA++; } else { JOptionPane.showMessageDialog(null,"You can do better!"); } break; } } JOptionPane.showMessageDialog(null,("You got " + correctA + " awnsers!")); s1 = JOptionPane.showInputDialog("Do you wish to play again: "); tempBoo= Integer.parseInt(s1); while (tempBoo < 0 || tempBoo > 3) { s1 = JOptionPane.showInputDialog("Invalid number, please use 1 or 2 and try again: "); tempBoo = Integer.parseInt(s1); } switch (tempBoo) { case 1: pAgain = true; break; case 2: pAgain = false; break; } } while (pAgain = true); JOptionPane.showMessageDialog(null,("Thank You For Playing")); } }