#include #include #include int main() { int x, y, z, invest, balance=100; int expected, result, guess; // Boolean srand(time(NULL)); printf("Let's start to play the game with 3 dices\n"); printf("Your balance = $%d\n\n", balance); do { do { printf("How much do you invest? $"); scanf("%d", &invest); } while ((invest <= 0) || (invest > balance) || (invest % 10 != 0)); do { printf("What is your expected outcome, big (1) or small (0)? "); scanf("%d", &expected); } while ((expected != 1) && (expected != 0)); x = rand() % 6 + 1; y = rand() % 6 + 1; z = rand() % 6 + 1; printf("The points of the 3 dices are %d %d %d\n", x, y, z); if (x + y + z >= 11) result = 1; else result = 0; if (expected == result) { balance = balance + invest; if (result == 0) printf("It is small, a correct guess\n"); else printf("It is large, a correct guess\n"); } else { balance = balance - invest; if (result == 0) printf("It is small, an incorrect guess\n"); else printf("It is large, an incorrect guess\n"); } printf("Your balance = $%d\n\n", balance); } while ((balance != 0) && (balance < 300)); if (balance == 0) printf("Game over, see you next time\n"); else printf("Congratulation, you win the game\n"); return 0; }