I'm struggling with my "IF" comparison between 3 variables. The program is supposed to comapare wheels 1, 2 and 3, and reward the player with £5 if all 3 are the same, and £2 if 2 of the 3 are the same.
However sometimes it doesn't work ( gives me £5 even though none are the same)
Please could someone take a look and tell me how to fix it?
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
const char *symbol[4] = {" bell ", " orange ", " cherry ", "horseshoe"};
int main ()
{
srand(time(NULL));
int playagain =1;
int wheel_1,wheel_2,wheel_3;
int i;
int money=10;
int j = (rand()%30)+10;
int start=1;
int k;
printf("you have £%d. Press any key to gamble £1\n", money);
getchar();
while(playagain == 1)
{
for (i=0; i<j; i++)
{
printf("\033[2J\033[0;0f");
printf("\033[%d;%df", 0, 0);
wheel_1 = (rand()%4);
wheel_2 = (rand()%4);
wheel_3 = (rand()%4);
printf("%s ", symbol[wheel_1]);
printf("%s ", symbol[wheel_2]);
printf("%s \n", symbol[wheel_3]);
for (k=0; k<10000000; k++)
{
}
}
printf("%d, %d, %d\n", wheel_1, wheel_2, wheel_3);
if (wheel_1 == wheel_2 == wheel_3)
{
printf("Congrats! You win £5\n");
money = (money+5)-1;
}
else if (wheel_1 == wheel_2 ||
wheel_1 == wheel_3 ||
wheel_2 == wheel_3 )
{
printf("Congrats! You win £2\n");
money = (money+2)-1;
}
else
{
printf("Unlucky, you have lost your £1\n");
money--;
}
printf ("You now have £%d\n", money);
char *replay;
printf ("would you like to play again?");
scanf ("%s", &replay);
if (strcmp(&replay, "yes") == 0)
{
playagain = 1;
}
else
{
playagain = 0;
}
}
}