c++11 - Basic C++ Dice game -
i have problem here, nice if me out here. first time using program dont judgemental.
#include <cstdlib> #include <iostream> using namespace std; int throw1, throw2, throw3, throw4; int bet1 = 100; int bet2 = 300; int bet3 = 500; int bet=(bet1, bet2, bet3); int deposit; int account; int main(){ int count = 0; while(count < 3){ cin>>deposit; while(deposit>5000 || deposit<0){ //makes sure deposit between 0-5000 cout<<"deposit failed"<<endl; cin>>deposit; } account = deposit; cout<<"you have deposited" <<deposit<<"swedish krona"<<endl; cout<<"and have cash on account"<<account<<"swedish krona"<<endl; if (konto>499){ //makes sure have money bet, , if dont have money, can put in more cout<<"please place bet"<<endl; cout<<"bet1=100, bet2=300, bet3=500"<<endl; cin>>bet1; cin>>bet2; cin>>bet3; account = (deposit - bet); cout<<"you have cash on account"<<account<<"swedish krona"<<endl; } else if(account>299){ cout<<"please place bet"<<endl; cout<<"bet1=100, bet=300"<<endl; cin>>bet1; cin>>bet2; account =(deposit - bet); cout<<"you have cash on account"<<account<<"swedish krona"<<endl; } else if(account>99){ cout<<"please place bet"<<endl; cout<<"bet1=100"<<endl; cin>>bet1; cout<<"you have placed bet"<<bet<<"swedish krona"<<endl; } while (account<100 || deposit>5000){ cout<<"insufficient funds"<<endl; cin>>deposit; account=deposit; } { cout<<"throw dice"<<endl; srand(time(0)); throw1 = rand() % 6 + 1; throw2 = rand() % 6 + 1; throw3 = rand() % 6 + 1; throw4 = rand() % 6 + 1; cout<<"you rolled"<<throw1<<endl; cout<<"you rolled"<<throw2<<endl; cout<<"computer rolled"<<throw3<<endl; cout<<"computer rolled"<<throw4<<endl; } } count++; system ("pause"); }
so thing here that, reason bet 500, though type in bet1 or bet2, , have no clue how fix problem. , loop function (int count 0; while(count < 3)count++)
starts loop endlessly without me pressing anything, though use same loop function in simple coding typing cout<< things works fine, when use in code, goes drain, know why happening, appreciate if answer, in advanced.
int bet1 = 100; int bet2 = 300; int bet3 = 500; int bet=(bet1, bet2, bet3)
the last line evaluated this: 100, 300, 500. result of comma separated list of expression last value, 500. bet variable set 500.
Comments
Post a Comment