Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is written in C++ Jeopardy Dice Note: This is part of Projects section and

ID: 3757166 • Letter: T

Question

This is written in C++

Jeopardy 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 submission 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 turnTotal 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 user.

Explanation / Answer

#include <iostream>
#include<stdlib.h>
#include <cstdlib>

#include <ctime>
#include<time.h>

using namespace std;
void plrTurn();
void computerTurn();
void winer(int);

int p_dice,c_dice,Pturn_total,compTurn_Total, playerScore,computerScore;
int main() {
int turnn;
cout<<"Press any key to know who rolls first ";
getchar();
turnn=1+rand()%2;
if(turnn==1)
{
cout<<"It's your turnn"<<endl;
plrTurn();

}

else
{
  
cout<<"It's computer's turnn ";
computerTurn();
}
return 0;
}

void plrTurn()
{ int c;

srand(time(NULL));
cout<<"Press enter to roll the dice: ";
getchar();
plrroll: p_dice=1+rand()%6;
cout<<" dice rolled: "<<p_dice;
if(p_dice==1)
{ playerScore+=1;
cout<<" It's computer's turnn now: ";
computerTurn();
}
else
{
Pturn_total+=p_dice;
cout<<" Enter 1 to roll or 2 to hold: ";
label: cin>>c;
switch(c)
{
case 1:
goto plrroll;
break;
case 2:
playerScore+=Pturn_total;
if(playerScore>=100)
winer(1);
else{
cout<<" It's computer's turnn now: ";
computerTurn();
}
break;
default: cout<<"Invalid choice! enter again: ";
goto label;

break;
}

}
}

void computerTurn()
{
srand(time(NULL));

roll: c_dice=1+rand()%6;
cout<<" computer rolled: "<<c_dice;
if(c_dice==1)
{ computerScore+=1;
cout<<" It's your turnn now"<<endl;
plrTurn();
}
else
{
compTurn_Total+=c_dice;
if(compTurn_Total>=25)
{ computerScore+=compTurn_Total;
cout<<" It's your turnn now"<<endl;
plrTurn();
}

else if(computerScore>=100)
{
  
winer(2);
}
else
goto roll;
}
  
}

void winer(int flg)
{
switch(flg)
{
case 1: cout<<" Congrats! You are the winer";
exit(0);
break;
case 2: cout<<" Sorry! The winer is the computer";
exit(0);
break;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote