Expert Answer
Executable code
//Include the needed package
import java.util.Random;
//Class
public class GamePrize
{
//Driver
public static void main(String[] args)
{
//Print
System.out.println(“Prize Description Value Booby”);
//Create instance
Random myRand = new Random();
//Initialize
int coinFlip = myRand.nextInt(2) + 1;
double valueOverall = 0;
int boobyValue = 0;
//Check condition
if(coinFlip==1)
{
//Print
System.out.println(“1. flipped heads $9.99 no A smartphone charger worth $9.99”);
//Update
valueOverall = 9.99;
}
//Otherwise
else
{
//Print
System.out.println(“1. flipped tails $0.49 yes a 9-volt battery and charger worth $0.49”);
//Update
valueOverall = 0.49;
//Update
boobyValue = 1;
}
int diceFlip = myRand.nextInt(6) + 1;
//Check condition
if(diceFlip==1)
{
//Print
System.out.println(“2. rolled 1 $1.49 no A refrigerator magent worth $1.49”);
//Increment
valueOverall += 1.49;
}
//Check condition
else if(diceFlip==2)
{
//Print
System.out.println(“2. rolled 2 $0.59 yes a handy grocery bag worth $0.59”);
//Increment
valueOverall += 0.59;
//Increment
boobyValue += 1;
}
//Check condition
else if(diceFlip==3)
{
//Print
System.out.println(“2. rolled 3 $4.00 no a half price ticket to next year fair worth $4.00”);
//Increment
valueOverall += 4.0;
}
//Check condition
else if(diceFlip==4)
{
//Print
System.out.println(“2. rolled 4 $12.00 no a CD ith hits from 12 bands playing at fair worth $12.00”);
//Increment
valueOverall += 12.00;
}
//Check condition
else if(diceFlip==5)
{
//Print
System.out.println(“2. rolled 5 $5.00 no a coupun for a free item at one of the concession worth $5.00”);
//Increment
valueOverall += 5.00;
}
//Otherwise
else
{
//Print
System.out.println(“2. rolled 6 $0.49 no a stuffed animal penguin worth $8.00”);
//Increment
valueOverall += 8.00;
}
int wheelSpin = myRand.nextInt(100) + 1;
//Check condition
if(wheelSpin>=1 && wheelSpin<=20)
{
//Print
System.out.print(“3. came up”);
//Check condition
if(wheelSpin%2==0)
{
//Print
System.out.print(” black ” + wheelSpin);
//Print
System.out.print(” $0.03 yes Money worth $0.03″);
//Increment
valueOverall += 0.03;
}
//Otherwise
else
{
//Print
System.out.print(” red “+ wheelSpin);
//Print
System.out.print(” $0.02 yes Money worth $0.02″);
//Increment
valueOverall += 0.02;
}
//Increment
boobyValue += 1;
}
//Check condition
else if(wheelSpin>=21 && wheelSpin<=40)
{
//Print
System.out.print(“3. came up”);
//Check condition
if(wheelSpin%2==0)
{
//Print
System.out.print(” black “+ wheelSpin);
//Print
System.out.print(” $12.00 yes Money worth $12.00″);
//Increment
valueOverall += 12.00;
}
//Otherwise
else
{
//Print
System.out.print(” red “+ wheelSpin);
//Print
System.out.print(” $8.00 yes Money worth $8.00″);
//Increment
valueOverall += 8.00 ;
}
}
//Check condition
else if(wheelSpin>=41 && wheelSpin<=60)
{
//Print
System.out.print(“3. came up”);
//Check condition
if(wheelSpin%2==0)
{
//Print
System.out.print(” black “+ wheelSpin);
//Print
System.out.print(” $3.00 yes Money worth $3.00″);
//Increment
valueOverall += 3.00;
}
//Otherwise
else
{
//Print
System.out.print(” red “+ wheelSpin);
//Print
System.out.print(” $2.00 yes Money worth $2.00″);
//Increment
valueOverall += 2.00;
}
}
//Check condition
else if(wheelSpin>=61 && wheelSpin<=80)
{
//Print
System.out.print(“3. came up”);
//Check condition
if(wheelSpin%2==0)
{
//Print
System.out.print(” black “+ wheelSpin);
//Print
System.out.print(” $6.00 yes Money worth $6.00″);
//Increment
valueOverall += 6.00;
}
//Otherwise
else
{
//Print
System.out.print(” red “+ wheelSpin);
//Print
System.out.print(” $4.00 yes Money worth $4.00″);
//Increment
valueOverall += 4.00;
}
}
//Otherwise
else
{
//Print
System.out.print(“3. came up”);
//Check condition
if(wheelSpin%2==0)
{
//Print
System.out.print(” black “+ wheelSpin);
//Print
System.out.print(” $9.00 yes Money worth $9.00″);
//Increment
valueOverall += 9.00;
}
//Otherwise
else
{
//Print
System.out.print(” red “+ wheelSpin);
//Print
System.out.print(” $6.00 yes Money worth $6.00″);
//Increment
valueOverall += 6.00;
}
}
//Print
System.out.printf(“nTotal Value: %.2fn”,valueOverall);
//Print
System.out.println(“Total booby prize “+ boobyValue);
//Print
System.out.println(“you also earned $”+ boobyValue*1.00 + ” prize for the contest”);
}
}