Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 fixevaluate 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 mainString args
String islands "Bermuda", "Bahama", "Jamaica", "Aruba",
"Martinique", "Antigua" ;
String activities parasailing"surfing", "snorkeling",
"DeepSeaFishing", "sailBoarding", "sharkSpotting",
"JetSkiing","scubaing", "shipwreck";
ImageIcon prizepng new ImageIconiconsprizepng;
JOptionPane.showMessageDialognull
"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.DEFAULTOPTION,
prizepng;
Random randGennew Random;
int island randGen.nextIntislandslength;
int activityrandGen.nextIntactivitieslength;
String activityFile"icons activitiesactivitypng;
File iconFile new FileactivityFile;
ificonFile.exists
System.out.print
cant see the file activityFile;
else
System.out.print
Can see the file activityFile;
String optionsGet another Trip","Quit";
ImageIcon iconnew ImageIconactivityFile;
String text
on islandsisland;
int choiceJOptionPane.showOptionDialognulltext,"Your Prize presented"
icon,options, options;
ImageIcon trippng new ImageIconiconsTrippng;
while true
ifchoice
JOptionPane.showOptionDialognulltext,"Your Prize presented"
icon,options, options;
else
JOptionPane.showMessageDialognull"Enjoy your prize program ending"
"Thank you for playing!!",JOptionPane.DEFAULTOPTION,trippng;
break;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started