in the race (placebet , userResponse) function the compiler is telling me that i have too many arguments. and i am confused. can someone edit and run this code for me please because i am confused and i cannot run it :(
#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <ctime>
void race (void);
int menu (void);
int placebet(void);
void init (void);
/*declaring variables*/
int money = 200;
usingnamespace std;
int main (void)
{
init();
int userResponse;
cout<<"welcome to the snail races !";
while (userResponse == menu());
switch (userResponse)
{
case 1:
case 2:
case 3:
::money+=
race (placebet, userResponse);
break;
case 4:
/*the user did not bet*/
race();
break;
}
}
return 0;
}
int menu (void)
{
std::cout;
std::cin;
cout<<"welcome to the snail races !!!"<<endl;
cout<<"you have "<<money<<" dollars"<<endl;
do {
cout<<"1) Bet on snail 1"<<endl
<<"2) bet on snail 2"<<endl
<<"3) bet on snail 3"<<endl
<<"4) just watch"<<endl
<<"0) leave the races"<<endl;
cin>>userResponse;
}while (userResponse < 0 && userResponse > 4);
return userResponse;
}
}
/*if the user chose to bet money*/
int race (int money , int userResponse)
{
std::cout;
std::cin;
cout<<"and the snails are off ! look at them go ! "<<endl;
int winner = rand () % 3+1;
cout<<"the winner is snail "<<winner<<endl;
if (winner == userResponse)
{
cout<<"yeah ! you win ! "<<endl;
return money * 2;
}
}
/*seeding the generator for the main function.*/
void init (void);
{
std::time;
std::rand;
std::srand;
srand (time (NULL));
}
int placebet (int userResponse)
{
using std::cout;
using std::cin;
int betAmount;
cout<<"snail "<<userResponse<<" is a good choice"<<endl;
cout<<"how much would you like to bet on you snail"
<<userResponse<<" ? ";
cin>>betAmount;
return betAmount;
}
/*if they are just watching the race */
void race (void)
{
race (0,0);
}
You need to make sure that function prototypes, function definitions and the use of the function in the program all agree in terms of the numbers and types of parameters sent.
A couple of other things...
I'm not sure what you're trying to do with this line? There is no valid value for userResponse when you first try to compare it to the result returned from the menu function.
while (userResponse == menu());
This is never going to be true - the same number can't both be less than zero and greater than 4.