import javax.swing.JOptionPane; public class RandomNumber{ public static void main(String args[]){ String random_result = ""; int a; int b; int powerof; boolean end = false; while(end==false){ a =(int)(Math.random()*4)+5; b =(int)(Math.random()*4)+5; powerof = (int)Math.pow(a, b); random_result = random_result+ a + " ^ " + b + " = " + powerof + "\n"; if(JOptionPane.showConfirmDialog(null,"Do you want to continue?","RandomNumber",JOptionPane.YES_NO_OPTION)==0){ end = false; }else{ end = true; } } JOptionPane.showMessageDialog(null,random_result); System.exit(0); } }