# (Solved Homework): 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;

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

Order NOW for a 10% Discount
Pages (550 words)
Approximate price: -

Why Us?

Top Quality and Well-Researched Papers

All ourbpapers are written from scratch. In fact, Clients who ask for paraphrasing services are highly discouraged. We have writers ready to craft any paper from scratch and deliver quality ahead of time.

Our writers keeps you posted on your papers progress - providing you with paper outline/draft. You are also at liberty to communicate directly with your writer.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time, in many cases quite ahead of time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.