Question: Can please fix / evaluate my java code so that it continues to generate random prizes until the user decides to select quit. It currently

Can please fix/evaluate my java code so that it continues to generate random prizes until the user decides to select quit. It currently will not generate a new vacation it insteads repeats the same one over and over and it also loops for a limited number of times when it should keep going until the user decides to quit.
import java.util.*;//RANDOM CLASS
import javax.swing.*;//JOPTIONPANE
import java.io.*;//CLASS FILE TO TEST VISIBILITY
public class ChooseAPrize
{
public static void main(String[] args)
{
String[] islands ={ "Bermuda", "Bahama", "Jamaica", "Aruba",
"Martinique", "Antigua" };
String[] activities ={"parasailing","surfing", "snorkeling",
"DeepSeaFishing", "sailBoarding", "sharkSpotting",
"JetSkiing","scubaing", "shipwreck"};
ImageIcon prize_png= new ImageIcon("icons/prize.png");
JOptionPane.showMessageDialog(null,
"This program will randomly generate"
+ "a grand prize"+"
"
+" that includes a trip to a carribean island and a "+
"
"
+ "two day pass for a specific island related activity"+"
"+"
"
+"Click on"
+" 'Okay' to see your next prize!!","Welcome to the prize chooser "
+ "presented by ",JOptionPane.DEFAULT_OPTION,
prize_png);
Random randGen=new Random();
int island= randGen.nextInt(islands.length);
int activity=randGen.nextInt(activities.length);
String activityFile="icons/"+ activities[activity]+".png";
File iconFile= new File(activityFile);
if(!iconFile.exists())
System.out.print("
cant see the file -"+activityFile);
else
System.out.print("
Can see the file -"+activityFile);
String[] options={"Get another Trip","Quit"};
ImageIcon icon=new ImageIcon(activityFile);
String text="
on "+islands[island]+"";
int choice=JOptionPane.showOptionDialog(null,text,"Your Prize presented"
+"",0,1,icon,options, options[0]);
ImageIcon trip_png= new ImageIcon("icons/Trip.png");
while (true)
{
if(choice==0)
JOptionPane.showOptionDialog(null,text,"Your Prize presented"
+"",0,1,icon,options, options[0]);
else
JOptionPane.showMessageDialog(null,"Enjoy your prize program ending"
,"Thank you for playing!!",JOptionPane.DEFAULT_OPTION,trip_png);
break;
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!