#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
usingnamespace std;
int main()
{
cout<<"Hey, welcome!"<<endl;
cout<<"Rules:"<<endl;
cout<<"1.if you get 7 or 11 you win the round!"<<endl;
cout<<"2.if you get 2,3 or 12 you loose"<<endl;
cout<<"3.If you get different number you have to repeat until you get your numer to win unless you get 7 you loose "<<endl;
cout<<"4.press(1) to throw"<<endl;
srand (time(NULL));
int dice_1,dice_2,result = 0, money = 100;
int number = 6;
int diceRoll = 0;
int roll = 1;
while (1)
{
cout<<"\nPress '1' to throw"<<endl;
cin>>diceRoll;
dice_1 = rand() % number + 1;
dice_2 = rand() % number + 1;
result = dice_1 + dice_2;
int round = 0;
while (money <=0 || round ==10);
if (round <=0);
{
int points = 0;
cout<< "Your score:"<<result<<endl;
if (roll == 1)
{
if (result == 2 || result == 3 || result == 12)
{
money = money - 30;
round++;
}
elseif (result == 7 || result == 11)
{
money= money+ 20;
round++;
}
else
{
points = result;
roll = 2;
}
cout<< "You have:"<<money<<endl;
cout<< "points:"<<points<<endl;
}
if (roll == 2)
{
cout<<"\n\n fight for your money!";
if (result == 7)
{
money = money - 30;
result = 0;
round++;
roll= 1;
}
elseif (points = result)
{
money= money + 20;
points= 0;
round++;
roll = 1;
}
else
{
money = money;
}
}
}
}
return 0;
}
it seems that the money in second part keep adding and the loop does not finish at round 10. I don't know hat i did wrong...
ok, I have change a bit to swich and cases:
sorry the code has a bit of polish, but anyway i hope you'll get it.
(by the way ths is my first week of learning)
I don't know what to do with case 4
I want from else to move to the beginning to case 4 until I'll get 4 or 7 (to determine if use looses or wins)