# Question & Answer: CPS 180-Programming Assignment #4 Assigned: 05/24/17 Due: 06/01/17 Points: 40 Purpose: Use data…..

CPS 180-Programming Assignment #4 Assigned: 05/24/17 Due: 06/01/17 Points: 40 Purpose: Use data types/variables, various selection structures, random number generation, input/output, performing calculations and formatting output. Description: You have just been given the opportunity to win prizes from a sweepstakes entry you made at the county fair! The opportunity includes winning 4 prizes, each will be determined by a different game of chance. You may create your own descriptions for the prizes and values as you like, just make sure they are patterned as follows. Each of these requires a random number generation. 1. Flip a coin: Depending upon the heads or tails result, you will get prizel: a. Heads: A smartphone charger worth S9.99 b. Tails: A 9-volt battery and a wire worth S0.49 (the booby prize) 2. Roll a six-sided die: Depending upon the number that comes up, you will get prize2: a. 1: A refrigerator magnet worth \$1.49 b. 2: A handy grocery bag worth S.59 (the booby prize) c. 3: A half-price ticket to next year’s fair worth S4.00 d. 4: A CD with hits from 12 bands playing at the fair worth S12.00 e. 5: A coupon for a free item at one of the concession stands worth 6: A stuffed animal penguin worth S8.00 3. Spin a roulette wheel: Depending on the color (red or black) and the number to 100), you will get prize3: a. Red doubles the prize, Black triples the prize b. Spin 1-20: Earn a penny (the booby prize) c. Spin 21-40: Earn \$4.00 d. Spin 41-60: Earn S1.00 e. Spin 61-80: Earn \$2.00 f Spin 81-100. Earn S3.00
This is the second time I post this question! Please do this lab to me and write it down that way I can copy it and paste it on the Java app!! Make a new one and don’t give me something you have already gave to someone else. Thanks

Executable code

//Include the needed package
import java.util.Random;

Don't use plagiarized sources. Get Your Custom Essay on
Question & Answer: CPS 180-Programming Assignment #4 Assigned: 05/24/17 Due: 06/01/17 Points: 40 Purpose: Use data…..
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS \$13/PAGE

//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”);
}
}