Question
I need to write a Kotlin program for the following. A player throws a six-sided die and scores as many points as the total shown
I need to write a Kotlin program for the following.
A player throws a six-sided die and scores as many points as the total shown on the die providing the die doesnt roll a 1. The player may continue rolling and accumulating points (but risk rolling a 1) or end his turn.
If the player rolls a 1 his turn is over, he loses all points he accumulated that turn, and he passes the die to the next player.
If the player ends without throwing a 1, the turn total is then added to the player's grand total.
Play passes from player to player until a winner is determined.
We are playing against the computer. The computer will roll the die using this rule:
A random number between 1 and 2 is CALCULATED. IF the number is a 1, the computer will roll. IF the number is a 2 it will stop rolling and give the dice back to the player. This loops until the calculated random number is a 2.
If a 1 is rolled, the turn is over and the computer loses all points from that turn. The sum of all the rolls of the dice during this turn are added to computer's grand total
The human player can choose from a menu whether to roll again or "hold" and allow the computer to have a turn.
The menu should look like this:
1. Roll Dice 2. Hold and pass to computer 3. Quit
Play is complete when either the computer or human reach 50 total points. The totals for both the computer and player must be shown each time along with the menu.
Correct header on top of program
Correct menu with 3 options
Rolling a 6 sided dice for each time needed
Turnscore is reset and turn is passed to computer when user rolls a 1
Turnscore is added to grand score when user passes to computer (whether on a 1 or choosing option 2 from menu)
Computer decides whether to roll based on a random number during their turn
Computer's turn score is incremented correctly
Computer loses turnscore and passes turn to user when a 1 is rolled
This criterion is linked to a Learning OutcomeGrand score is updated correctly for both user and computer and is displayed each time with the menu
When option 3 is selected from menu, grand score is updated and program prints out final score and quits
Properly formatted code (2 spaces for indentation) and not excessive extra blank lines
Properly formatted code (2 spaces for indentation) and not excessive extra blank lines
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started