Difference between revisions of "Week 6"
Line 3: | Line 3: | ||
|ProblemName=Roulett | |ProblemName=Roulett | ||
− | |Problem=Write a complete program Roulett that prints out total gained from player.<br/> | + | |Problem= Please read the following carefully, and Write a complete program Roulett that prints out total gained from player.<br/> |
− | + | Each game will be running for 6 turns. Player will take the first turn <br/> | |
− | + | followed by the opponent. You need to generate a double random number <br/> | |
− | + | each time that will represent the chance of getting shot. <br/> | |
− | + | If the chance is smaller than the probability, then the bullet is fired.<br/> | |
− | + | First turn, the probability starts at 0.2. After the first turn, you have to increase the probability. <br/> | |
− | + | It will increase 0.1 for first four times, then, it will increase 0.25 for the 5th and the 6th time.<br/> | |
− | + | If the player wins the player gets $ 50 dollars, otherwise the player loses $ 50 dollars.<br/> | |
− | + | The starting money of the player will be $ 100 dollars.<br/> | |
− | + | <br/> | |
− | + | 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)<br/> | |
− | + | <br/> | |
− | + | Print out the output (money of the player) using JOPtionPane.<br/> | |
|SolutionCode=<pre>import java.lang.Math.*; | |SolutionCode=<pre>import java.lang.Math.*; |
Revision as of 14:35, 5 April 2010
Back to the Program-A-Day homepage
ProblemPlease read the following carefully, and Write a complete program Roulett that prints out total gained from player. |
...by students
An image or By Students section | |
---|---|---|
SolutionThe solution... | ||
Code |