7 / 11 dice game. while loops and with points and stuff

Write your question here.
So i have this project where in we are to make a 7/11 dice game.
Somehow, i just can't get it :<
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <windows.h>
#include "conio.h"

#include <iostream>
#include <math.h>
#include <time.h>
using namespace std;
HANDLE console =GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorPosition;
void gotoXY(int x, int y);
int roll()
{
   return(rand() % 6 + 1);
}

int main()
{
  int stake = 500, tpoints = 0, bet = 0, point = 1;//new edit here
  int choice = 0;
  int roll1, roll2, sum;
  char again;

  srand(time(NULL));  //seed

  cout << "7 11 DICE GAME!!" << endl;
  roll1 = roll();
  roll2 = roll();
//  sum = roll1 + roll2;
 // cout << "First dice roll: " << roll1 << " + " << roll2 << " = " << sum << endl;

 // while (stake > 0)
  do
  {//first while bracket
      
    
     cout << "(0) quit or (1) bet? ";
     cin >> choice;
     if (choice == 1) {
        cout << "how much? only by fives. ";
        cin >> bet;
        while ((bet % 5 != 0) || (bet < 0) || (bet > 500))
        {
           cout << "Illegal bet--please bet again:" << endl;
           cout << "How much? ";
           cin >> bet;
        }
        roll1 = roll();
        roll2 = roll();
        sum = roll1 + roll2;
        cout << "Roll: " << roll1 << " + " << roll2 << " = " << sum << endl;
        if ((sum == 2) || (sum == 3) || (sum == 12))
        {
           cout << "You lose!  try again!" << endl;
           stake -= bet;
           tpoints -= point;
        }
        else if ((sum == 7) || (sum == 11))
        {    
           cout << "You win!  try again!" << endl;
           stake += bet;
           
           
        }
        else if ((sum == 4) || (sum == 5) || (sum == 6) || (sum == 8) || (sum == 9) || (sum == 10))
        {
           cout << "1 point!" << endl;
           tpoints += point;
           cout<<"Bet? (y/n)"<<endl;
           cin>>again;
           }
     }
      //system ("cls");
     gotoXY (50,2); cout << "Stake = " << stake << endl;
     gotoXY (50,3); cout << "Points = " << tpoints<<endl;
     }//end while bracket
     while (again =='y' || again == 'Y');
       //else
        system ("pause");
        return(0);
  }

void gotoXY(int x, int y)

{
     CursorPosition.X = x;
     CursorPosition.Y = y;
     SetConsoleCursorPosition(console, CursorPosition);
}
Last edited on
Topic archived. No new replies allowed.