Question
I need help working on this project. My function for the human user's turn is not working. Here is my code: int rollDice() { return
I need help working on this project. My function for the human user's turn is not working. Here is my code:
int rollDice()
{
return random() % 6 + 1;
}
void welcomeGame()
{
cout
}
int humanTurn()
{
int stillTurn;
stillTurn=1;
char rollAgain, wantRoll, answer;
wantRoll='N';
int turnTotal;
cout
if(stillTurn
{
cout
cin >> wantRoll;
if ((wantRoll != 'N' || wantRoll != 'n')
&& (rollAgain !='N'|| rollAgain !='n'))
{
switch (rollDice()) {
//six different dice roll outcomes
case 1:
case 6:
turnTotal=0;
cout
stillTurn=false;
case 3:
turnTotal=15;
cout
stillTurn=false;
case 2:
turnTotal=+2;
break;
case 4:
turnTotal=+4;
break;
case 5:
turnTotal=+5;
break;
}
cout
cout
cin >> answer;
if(answer=='y'||answer=='Y'){
rollAgain='y';}
else{
rollAgain='n';}
}
}
}
void game()
{
int computerTurn = 0;
int compTotal = 0;
int humanTotal = 0;
welcomeGame();
humanTurn();
}
int main()
{
// start the game!
game();
return 0;
}
However, the loop runs a single time, asks the user if they would like to roll again, but does NOT loop back through. If you could help me get this function working correctly within the rules of the game, I could finish the project. Thank you in advance!
leopardy Dice Note: This is part of Projects section and constitutes to 5% of your grade This project's objective is to create a Jeopardy Dice game in which one player (the user) competes against the computer to reach 100 points. You will turn in one file called jeopardy_dice.cpp. Read this document about the standards for homework submissioin before you turn you work in. Game Mechanics There are two players: the user and the computer, who alternate turns until one of them reaches 100 points or higher. The user is always the first player and starts the game. If any player reaches 100 points or more at the end of their turn, the game ends immediately and the other player does not get another turn During one turn the player(either the user or computer) accumulates turnTota.l over a series of dice rolls. If they roll a 1 or 6, their turn ends and the turnTotal becomes 0. If they roll a 3, their turn ends and turnTotal becomes 15 (irrespective what they collected up to that roll) If they roll a 2,4,5, the value on the dice accumulates to turnTotal The value on the dice is selected randomly during every roll o o o o At the end of the turn, turnTotal is accumulated to playerTotal(either user or computer based on the turn) During a turn, before each roll, if the player is the user, they are given two options: Continue rolling Hold; if the user chooses to Hold the user's turn ends and the turn is passed to the computer. o o If the player is the computer, they will always continue rolling until their turn total reaches the value 10 or higher. If the turnTotal for the computer is 10 or higher, the computer's turn ends and the turn is passed to the userStep 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