Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A Dice Game Called Chicago Due Date TBD Before Starting the Project Complete the zyBooks 1 0 8 Review Reading and Labs Read this entire
A Dice Game Called Chicago
Due Date
TBD
Before Starting the Project
Complete the zyBooks Review Reading and Labs
Read this entire project description before starting
Learning Objectives
After completing this project you should be able to:
write functions to meet specific requirements
write conditional statements with boolean expressions
write a looping construct
develop a collection of functions
Game Rules
The game requires two sixsided dice.
Players take turns until all eleven rounds have been played. The goal is to roll all possible combinations for two dice, More than two people can play but not for this project.
Players begin the first round by rolling both dice. If a player rolls each die is then points are added to the players score. Play continues with the next goal to roll Play ends after the eleventh round, where players try to roll
The player with the highest point total is the winner.
Step : Create a New CLion or Codeblocks Project
Step : Create and test the functions below in the specified order given
You must maintain the function and variable names. Do not create additional functions or make any changes to the following requirements without approval from your instructor.
Functions
int rollDie Call the randfunction to simulate rolling a single sided die. Refer to zyBooks for more information about the random library. Return the value. This function is called by several other functions.
Parameters: none
Returns: a random value between and
Your Testing: Call rollDie two times in main using the printf function and appropriate placeholders. You should notice that the two values are integer values from to You will also notice that if you rerun your program, the values will always be the same. This does not seem very random for playing a real dice game, so we can use the srand function along with a seed value for current time to allow a new combination to be created every time the program is started. You will need to include the time.h library and call the srand function with time as the argument within main. Only do this once. Rerun your program many times and pay attention to the returned values. They should change each time.
Out Testing: copy your partial solution to zyBook for initial testing. Select Submit Mode and then Submit for grading of tests should pass
int playerTurnint round performs a players turn for a given round. The playercomputer is provided a round goal starting at rolling two ones Turn total starts at zero. Call rollDie twice to roll both dice and store the values in their own integer type variable. If the sum of the two dice equals the round goal the turn total is replaced by this value and returned. Otherwise, the turn total is returned as zero. Print the rolled dice and turn score after each roll. At the end of the turn, return the updated gamescore.
Ex: for round :
Die Value:
Die Value:
Round Score:
for round :
Die Value:
Die Value:
Round Score:
Parameters: goal for this turn
Returns: turn total
Your Testing: Testing code with randomness is challenging. Your best approach is to call playerTurnround many times with different arguments and pay attention to the output.
playerTurn
Out Testing: copy your partial solution to zyBook for additional testing. of tests should pass
char playerVSplayerallows two players and to play a single game. You should begin each players score at and use a for loop to play the eleven rounds calling the playerTurnround function for each player. The winner is returned as a char, A for player and B for player Sample output:
Round :
Player One's Turn:
Die Value:
Die Value:
Round Score:
Player Two's Turn:
Die Value:
Die Value:
Round Score:
Player score:
Player score:
Player One Wins!
Design Requirement: Use a for loop
Parameters: none
Returns: winner
Your Testing: Testing code with randomness is challenging. Your best approach is to call playerVSplayer many times and pay attention to the output.
Out Testing: copy your partial solution to zyBook for additional testing. of tests should pass
void worldChampionshipint games allows two computer players to play each other a certain number of games. For example, play seven games and determine which player wins the most. After all games are complete, print results for player and player
Sample output after nine games:
Player Total Wins:
Player Total Wins:
Design Requirement: Use a for loop for the number of games.
Parameter: number of games
Returns: none
Your Testing: Testing code with randomness is challenging. Your best approach is to call worldCham
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