Question: This is beginning program.ming only. It MUST be written in FLOWGORITHM. No Java or any other language as I am usinga self teachinng study that
This is beginning program.ming only. It MUST be written in FLOWGORITHM. No Java or any other language as I am usinga self teachinng study that starts with flowgorithm and psuedocode. Please again write the program in FLOWGORITHM. Thanks
Dice game
Create the following game menu:
Select a Game:
1.One Die 2.Four Dice 3.Four Dice with Reroll 4.Stats 5.Game Over
Repeat the game menu until the player chooses option 5 or until one of the players gets 5 wins. Error check the user input for the menu, reprompting until they enter a valid menu number.
1. One Die
Create a 2 player dice game where each player rolls one 6 sided die and the player with the highest number wins.
Use the built in random(n) function to simulate a rolling a 6 sided die.
Write functions for the following:
Roll: returns the result of one dice roll
2. Four Dice
Create a 2 player dice game where each player rolls 4 dice and the the player with the highest total wins. Simulate a turn for each player. Roll 4 dice for each player, total the values and the player with the highest total wins.
Create an array for each player and store each dice roll in each player's array.
Use the built in random(n) function to simulate a rolling a 6 sided die.
It would be recommended you write functions for:
RollAll: takes an array as an argument and fill it with dice rolls, doesn't need to return the array because arrays are passed by reference
Total: takes an array as an argument and returns the total of all the numbers stored in that array.
DisplayDice: takes an array as an argument and returns a string that has the the values from the array all in one line separated by spaces or commas. You can do that by having a string accumulator and concatenating each value from the array on to the string one value at a time.
3.Four Dice with Reroll
Enhance the Four Dice game so that after the all the dice have been rolled for both players, each play may reroll all their dice one.
Roll all the dice for both players and then display the totals.
Ask each player if they would like to reroll their dice.
If they answer yes reroll ALL of the dice in their array.
Error check this users answers, only accepting y or n.
After each player has been given the chance to reroll once, output the final totals and then determine and display the winner.
4.Stats
Update the program so it keeps track of how many games have been played, the wins for player1 and the wins for player2. When this option is selected display those statistics.
5.Game Over
This option should display Game Over and end the program
Suggested Approach:
Start with the menu first, get it looping and error checking
Add the variables necessary for the stats in the main
Add the One Die game in the main, having it update the appropriate stats variable.
Modify the menu loop to have it also stop not only on the Game Over choice but also if a player reaches 5 wins.
If you want to put any of the game logic in a function you can have it return a representation of who won the game; one value if p1 wins, something else for p2 win and a third value for a tie. Then have logic in the main to use that return value from the game function and update the appropriate game stats. That isn't the only way how to do it but it's fairly straight forward.
Below is some sample data that I was came up with so that you can see what I am trying to get in the end.
Select a Game: 1.One Die 2.Four Dice 3.Four Dice with Reroll 4.Stats 5.Game Over
->1 One Die Player 1 rolled: 3 Player 2 rolled: 2 Player 1 wins!
Play again? Select a Game: 1.One Die 2.Four Dice 3.Four Dice with Reroll 4.Stats 5.Game Over
Thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
