Week 6

From CompSciWiki
Revision as of 14:36, 5 April 2010 by JaeManL (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

Please read the following carefully, and Write a complete program Roulett that prints out
total gained from player.

Each game will be running for 6 turns. Player will take the first turn
followed by the opponent. You need to generate a double random number
each time that will represent the chance of getting shot.
If the chance is smaller than the probability, then the bullet is fired.
First turn, the probability starts at 0.2. After the first turn, you have to increase the probability.
It will increase 0.1 for first four times, then, it will increase 0.25 for the 5th and the 6th time.
If the player wins the player gets $ 50 dollars, otherwise the player loses $ 50 dollars.
The starting money of the player will be $ 100 dollars.

Example. 1st(player, 0.2), 2nd(opponent, 0.3), 3rd(player, 0.4), 4th(opponent, 0.5), 5th(player, 0.75), 6th(opponent, 1.0)

Print out the output (money of the player) using JOPtionPane.

 

...by students

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution...

Code

Solution Code

Back to the Program-A-Day homepage