Answered step by step
Verified Expert Solution
Link Copied!

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 108 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 six-sided dice.
Players take turns until all eleven rounds have been played. The goal is to roll all possible combinations for two dice, 212. More than two people can play but not for this project.
Players begin the first round by rolling both dice. If a player rolls 2(each die is 1), then 2 points are added to the players score. Play continues with the next goal to roll 3. Play ends after the eleventh round, where players try to roll 12.
The player with the highest point total is the winner.
Step 1: Create a New CLion (or Codeblocks) Project
Step 2: 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 rand()function to simulate rolling a single 6-sided die. Refer to zyBooks 2.20 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 1 and 6
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 1 to 6. 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(0) 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 10.1 for initial testing. Select Submit Mode and then Submit for grading(1 of 6 tests should pass).
int playerTurn(int round)- performs a players turn for a given round. The player/computer is provided a round goal starting at 2(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. 1) If the sum of the two dice equals the round goal, the turn total is replaced by this value and returned. 2) 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 game_score.
Ex: for round 2:
Die 1 Value: 1
Die 2 Value: 1
Round Score: 2
for round 8:
Die 1 Value: 2
Die 2 Value: 5
Round Score: 0
Parameters: goal for this turn
Returns: turn total
Your Testing: Testing code with randomness is challenging. Your best approach is to call playerTurn(round) many times with different arguments and pay attention to the output.
playerTurn(4)
Out Testing: copy your partial solution to zyBook 10.1 for additional testing. (3 of 6 tests should pass).
char playerVSplayer()allows two players (1 and 2) to play a single game. You should begin each players score at 0 and use a for loop to play the eleven rounds (212), calling the playerTurn(round) function for each player. The winner is returned as a char, A for player 1, and B for player 2. Sample output:
Round 12:
Player One's Turn:
Die 1 Value: 6
Die 2 Value: 6
Round Score: 12
Player Two's Turn:
Die 1 Value: 6
Die 2 Value: 3
Round Score: 0
Player 1 score: 20
Player 2 score: 9
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 10.1 for additional testing. (4 of 6 tests should pass).
void worldChampionship(int 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 1 and player 2.
Sample output after nine games:
Player 1 Total Wins: 4
Player 2 Total Wins: 5
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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

Students also viewed these Databases questions