Question
URGENT! PLEASE HELP!!! I keep getting errors for this lab assignment that requires C++, please help me revise my code so i can finish this
URGENT! PLEASE HELP!!!
I keep getting errors for this lab assignment that requires C++, please help me revise my code so i can finish this assignment. Thank you, Thank you, Thank you a million times over for this.:
Error Message:
Code:
#include
#include
#include
#include
using namespace std;
void generate_summary(vector
//generates summary
{
int i;
int largest_wager = INT_MIN, smallest_wager = INT_MAX;
int largest_winning = INT_MIN, smallest_winning= INT_MAX;
cout
for (i=0 ; i
{
cout
largest_wager = max( largest_wager ,wager[i]) ;
smallest_wager = min( smallest_wager,wager[i]) ;
largest_winning = max( largest_winning,winning[i]) ;
if(winning[i]>0) // find smallest win having positive value
smallest_winning = min( smallest_winning,winning[i]) ;
}
if(smallest_winning==INT_MAX) smallest_winning=0 ; // no wins
cout
cout
cout
cout
cout
}
int main()
{
unsigned int seed ; //seed
int bet , money =1000 ,i ;
int reel[3] ;
vector
printf("Input a seed: ") ;
cin >> seed ; //seed value
while(cin.fail()) // input until seed is valid
{
cin.clear();
cin.ignore(256,' ');
printf("Input a seed: ") ;
cin >> seed ;
}
cout
cout
cin >> bet ;
if(bet==0)
{
cout
return 0 ;
}
srand(seed);// seed the random results
while(1) // game starts
{
if(bet==0)
{
generate_summary(wager,winning) ; // function call
break ;
}
while(bet > money)
{
cout
cout
cin >> bet ;
if(bet==0)
{
generate_summary(wager,winning) ; // function call
break ;
}
}
wager.push_back(bet) ; // push bet to wager vector
for(i=0; i
{
int random_no = 2 + ( rand() % 8 ) ; //random int between [2,7]
reel[i] = random_no ;
}
cout
if(reel[0] == reel [1] == reel[2]) // if all reel values are equal
{
if(reel[0]==7) // jackpot !
{
cout
winning.push_back(10*bet) ;
money = money + 10 * bet ;
}
else // reel values equal but other than 7
{
cout
winning.push_back(2*bet) ;
money = money + 2 * bet ;
}
}
// if exactly two reel value matches
else if(reel[0] == reel[1] || reel[0] == reel[2] || reel[1] == reel[2])
{
cout
winning.push_back(2*bet) ;
money = money + 2 * bet ;
}
else // all reel values are distinct
{
cout
winning.push_back(0) ;
money = money - bet ;
}
cout
cout
cin >> bet ; //place next bet
}
return 0;
}
tshahid: tesla4 g++ -std-c++11 -Wall -o lab5 lab5.cpp Lab5.cpp: In function 'void generate summary(std::vector
Step 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