CST8110 | Assignment 3 - Gambling | Complete Solution
- ExpertT
- Rating : 109
- Grade : A+
- Questions : 1
- Solutions : 1026
- Blog : 0
- Earned : $53187.54
Introduction to Computer Programming - CST8110
Assignment 3 - Gambling
Rules
Assignments are expected to be done individually. However, it is ok to share ideas or discuss
with peers. Do not copy/paste or transcribe code from each other or the web. This way your
work will keep some of its originality.
1 Solitaire Dice
This assignment involves a game invented by Howard Rosenblum, the CST8110 coordinator,
which he calls Solitaire Dice.
• The game is played alone.
• The player starts with a pot of money (e.g. $100).
1. The player chooses a bet amount less than or equal to his current pot.
– Invalid amounts are ignored, the player must specify another bet amount. [1 pts]
– A bet of $0 means the player wants to quit the game. [1 pts]
2. The game will remove their bet amount from the pot. [1 pts]
3. The game will roll three 6-faced dices and display the values rolled. [1 pts]
4. The game will adjust the pot in the following order of priority:
– If all three dices have the same value, then the player wins triple their bet back.
[1 pts]
– If two of the three die have the same value, then the player wins double their bet
back. [1 pts]
– If the total of the three dice is strictly greater than 10, then the player wins their
bet back. [1 pts]
– Otherwise, the player has lost their money.
– It is not possible to get multiple results simultaneously. [1 pts]
5. The game ends automatically if the pot reaches 0. [1 pts]
• Coding Style: Variable names are sensible (i.e. meaningful). [1 pts]
• BONUS: Betting the character ? (question mark) bets a random amount of money (within
the valid range, excluding $0). [0.5 pts]
• BONUS: Betting the character ~(tilde) is considered cheating, as it adds $100 to your pot.
[0.5 pts]
• The program does not compile. [-10 pts]
1
1.1 Hints
• You can use break to exit the loop completely (e.g. when the user bets $0).
• You can use continue to skip the rest of the loop’s body (e.g. when the user bets an invalid
amount).
• You should use the && logical operator (AND) when testing for triples.
• You should use the || logical operator (OR) when testing for doubles.
1.2 Runtime Examples (the text in blue is user input)
Pot: $100
Bet amount: $100
The rolls are: 2 3 4
Better luck next time.
Get out. You are broke.
Pot: $100
Bet amount: $50
The rolls are: 5 2 4
High roll, you get your bet back.
Pot: $100
Bet amount: $50
The rolls are: 2 5 5
Double!
Pot: $150
Bet amount: $?
You randomly bet $108
The rolls are: 4 5 5
Double!
Pot: $258
Bet amount: $~
Cheat: Free Money
Pot: $358
Bet amount: $0
Take care.
What to submit
• Submit your .java file in Blackboard.
• Your programs must compile.
• If you can’t complete the assignment, submit what you have.
[Solved] CST8110 | Assignment 3 - Gambling | Complete Solution
- This solution is not purchased yet.
- Submitted On 27 Dec, 2017 08:25:31
- ExpertT
- Rating : 109
- Grade : A+
- Questions : 1
- Solutions : 1026
- Blog : 0
- Earned : $53187.54