/*
Name : Dedy Purwanto
ID : I07007472
*/
import javax.swing.JOptionPane;
public class MyRandom{
public static void main(String args[]){
String random_result = ""; // To keep all of the random result
int random1; // To keep first random value
int random2; // To keep second random value
int powerof; // To keep the value of random1 power of random2
boolean end = false; // To indicate wheter the looping has finished or not
while(end==false){ // Start the looping
random1 (int)(Math.random()*4)+5; // Generate first random value
random2 = int)(Math.random()*4)+5; // Generate second random value
powerof = (int)Math.pow(random1, random2); // Calculate random1 power of random2
random_result += random1 + " ^ " + random2 + " = " + powerof + "\n"; // Append to message
/* If user click No, then end the looping */
if(JOptionPane.showConfirmDialog(null,"Do you want to continue?","MyRandom",JOptionPane.YES_NO_OPTION)==0){
end = false;
}else{
end = true;
}
}
// Display the message
JOptionPane.showMessageDialog(null,random_result);
// Exit the program
System.exit(0);
}
}