Question: My code for trifecta and trifectabox doesn't follow the cheat results #include #include #include #include #include #include #include using namespace std; class Race { private:
My code for trifecta and trifectabox doesn't follow the cheat results #include
#include
#include
#include
#include
#include
#include
using namespace std;
class Race
private:
int horses;
public:
Race
srandtimeNULL; Set the random seed
void readySetGo
int n sizeofhorses sizeofhorses;
for int i ; i n; i
int randomValue i randn i;
int randomElement horsesrandomValue;
horsesrandomValue horsesi;
horsesi randomElement;
;
int first
return horses;
int second
return horses;
int third
return horses;
int fourth
return horses;
;
bool exactaarray picks, array winner
return picks winner && picks winner;
bool exactaBoxarray picks, array winner
bool a picks winner && picks winner;
bool b picks winner && picks winner;
return a b;
bool trifectaarray picks, array winner
return picks winner && picks winner && picks winner;
bool trifectaBoxarray picks, array winner
sortpicksbegin picks.end;
sortwinnerbegin winner.end;
return picks winner && picks winner && picks winner;
int main
int balance ;
Race race;
cout "Welcome to the horse race betting program!
;
while true
race.readySetGo;
cout "The Cheat: race.first race.second
race.third race.fourth endl;
cout "Enter your bet eg 'exacta 'trifectabox 'balance', 'exit': ;
string input;
getlinecin input;
vector words;
stringstream ssinput;
string word;
while ss word
words.pushbackword;
if wordsempty
cout "Invalid input. Please try again.
;
continue;
string command words;
if command "exit"
cout "Exiting program.
;
break;
else if command "balance"
cout "Your current balance: $ balance endl;
continue;
else if command "exacta" && command "exactabox" && command "trifecta" && command "trifectabox"
cout "Invalid command. Please enter a valid bet command.
;
continue;
array picks;
array picks;
for sizet i ; i words.size; i
if i
picksi stoiwordsi;
else
picksi stoiwordsi;
int betCost;
if command "exacta" command "exactabox"
betCost ;
else
betCost ;
if balance betCost
cout "Insufficient balance to place the bet.
;
continue;
balance betCost;
bool win;
if command "exacta"
win exactapicks race.first race.second;
else if command "exactabox"
win exactaBoxpicks race.first race.second;
else if command "trifecta"
win trifectapicks race.first race.second race.third;
else if command "trifectabox"
win trifectaBoxpicks race.first race.second race.third;
if win
int winnings;
if command "exacta" command "exactabox"
winnings ;
else
winnings ;
balance winnings;
cout "Congratulations! You won $ winnings
;
else
cout "Sorry, you lost the bet.
;
cout "Your current balance: $ balance endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
