Answered step by step
Verified Expert Solution
Link Copied!

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 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="

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions

Question

What is PKI, and why is it important?

Answered: 1 week ago