Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

can someone help me fix my homework im trying to make it so you can say yes or no to roll or not #include #include

can someone help me fix my homework im trying to make it so you can say yes or no to roll or not

#include #include using namespace std;

///function to roll die /// returns number betweeen 1 to 6 int rollDie() { return (rand() % 6+1); }

/// function to ask optons to human void askYoNs(){ cout<<"Do you want to roll a dice (Y/N)?:"<

///function that takes arguments and prints scores void printScores(int turnTotal,int humanTotal,int compTotal){ cout<<"Your turn total is "<

/// function to process current die roll /// turnTotal ,humanTotal and computerTotal are referrence args whose contents can be chnaged within the function int process(int& turnTotal,int roll,int curr_player,int& humanTotal,int& computerTotal) { if(roll==2 || roll==5) ///turn ends & turnTotal=0 { ///switch player curr_player=changePlayer(curr_player); turnTotal=0; printScores(turnTotal,humanTotal,computerTotal); } else if(roll==4) ///turn ends & turnTotal=15 { turnTotal=15; ///switch player if(curr_player==human) humanTotal+=turnTotal; else computerTotal+=turnTotal; curr_player=changePlayer(curr_player); turnTotal=0; printScores(turnTotal,humanTotal,computerTotal); } else{ ///roll = 1 3 6 turnTotal+=roll; cout<<"Your turn total is "<=10 ///then switch player if(curr_player!=human && turnTotal >=10 ){ computerTotal+=turnTotal; curr_player=changePlayer(curr_player); turnTotal=0; printScores(turnTotal,humanTotal,computerTotal); }

return curr_player; }

void game() { int player=human; int humanTotal=0; int computerTotal=0; int turnTotal=0;

if (turnTotal==0){ cout<<"Welcome to Jeopardy Dice!"<>YoN; if(YoN=='n') ///hold { humanTotal+=turnTotal; player=1; ///switch player to Computer printScores(turnTotal,humanTotal,computerTotal); turnTotal=0;

continue; } } else cout<

}///while ends here

///check who is winner if(humanTotal>=80) {

cout<<"Congratulations! human won this round of Jeopardy Dice!"<

cout<<" !!! COMP WON !!! "<

}

}

int main() { game();

return 0; }

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

More Books

Students also viewed these Databases questions

Question

By definition the below drawing is tree. True / False

Answered: 1 week ago