### I need help with this program. I am new in Programming and I need to write this program asap. Thanks

hi
Last edited on
Whst do you need help with, and what have you written so far? We aren't exactly going to just do your homework for you, though we can help you fix specific problems that you may encounter.
g
Last edited on

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205`` ``````#include #include #include #include using namespace std; int Dice(int DV[], int Roll = 2); void gameCraps(int sum, int Balance, int wager); enum Status {CONTINUE, WON, LOST}; int main() { int sum, bAccount; int DV[2]; int Balance = bAccount; int wager; srand(time(0)); sum = Dice(DV); cout << " ____________ ________ _________ _________ _______ " <>bAccount; cout << "\nYour bank balance is: " << "\$" << bAccount << "\n"; cout << "Please enter a wager - "; cin >> wager; if (wager > bAccount) { cout << "Not valid" << endl; cout << "Please enter a wager - " << endl; cin >> wager; } cout << "\n" << "Your wager: " << "\$" << wager << "\n\n"; cout << "Player rolled: " << DV[0] << " + " << DV[1] << endl; gameCraps(sum, Balance, wager); return 0; } int Dice(int DV[], int Roll) { int dicevalues = 0; for(int i = 0; i < Roll; i++) { DV[i] = 1 + rand()%6; } for(int i = 0; i < Roll; i++) { dicevalues = dicevalues + DV[i]; } return dicevalues; } void gameCraps(int sum, int Balance, int wager) { int Point; int DV[2]; char userchoice; Status gameStatus; switch(sum) { case 7: gameStatus = WON; case 11: gameStatus = WON; break; case 2: gameStatus = LOST; case 3: gameStatus = LOST; case 12: gameStatus = LOST; break; default: gameStatus = CONTINUE; Point = sum; cout << "Point is: " << Point << endl; break; } if(sum==WON) cout << "player wins" <> userchoice; if (userchoice == 'y') { cout << "Good luck!!\n"; gameStatus = CONTINUE; } while (gameStatus == CONTINUE) { sum = Dice(DV); cout << "Your bank balance is: " << "\$" << Balance << "\n"; cout << "Please enter a wager - "; cin >> wager; cout << "\n" << "Your wager: " << "\$" << wager << "\n\n"; cout << "Player rolled: " << DV[0] << " + " << DV[1] << endl; gameCraps(sum, Balance, wager); } if (userchoice == 'n') { cout << "You go away with a bank balance of " << "\$" << Balance << "\n"; exit(0); } if (userchoice !='n' || userchoice !='y') { cout << "Please enter a valid choice ('Y' or 'N')\n"; exit(-1); } } else { cout << "\n\t***Player loses***\n" << endl; Balance = Balance - wager; if (Balance <= 0) { cout << "Sorry, you don't have enough cash to continue! Please try again.\n"; cout << "Your bank balance is now " << "\$" << Balance << "\n"; exit(-1); } if (Balance > 0 ) { cout << "Would you like to continue or cash out?" << endl; cout << "select 'Y' to continue . select 'N' to cash out\n" << endl; cin >> userchoice; if (userchoice == 'y') { cout << "Good luck my friend!!!\n"; gameStatus = CONTINUE; } while (gameStatus == CONTINUE) { sum = Dice(DV); cout << "Your bank balance is: " << "€" << Balance << "\n"; cout << "Please enter a wager - "; cin >> wager; cout << "\n" << "Your wager: " << "\$" << wager << "\n\n"; cout << "Player rolled: " << DV[0] << " + " << DV[1] << endl; gameCraps(sum, Balance, wager); } if (userchoice == 'n') { cout << "Thanks for playing! You go away with a balance of " << "\$" << Balance; exit(0); } if (userchoice !='y' || userchoice !='n') { cout << "Please enter a valid choice to continue\n"; exit(-1); } } } } }``````
Sorry, I don't know how to make it to read like what it is in source file.

Can someone help me with this program please?
Here are the rules:

* If player roll 7 or 11 on the first roll, they win, if s/he roll 2, 3, or 12, they lose.

* If a player does not win or lose on the first roll, that total establishes the "point".

*The player then continues to roll until, the "point" is rolled, in which case he wins or a 7 is rolled, in which case he loses. There is no limit on the number of subsequent rolls. Just keep rolling until a 7 or the "point" is rolled.

*If the player's point is an even number (4, 6, 8, 10) ask if he wants to bet the "hard way". If so, prompt for bet. The "hard way" is a one roll bet that pays double the wager if he gets his points with a pair.

* Once a player wins or loses, that is a game and it all starts over unless he wants to cash out.

*
First question. How is it when you create the bank account you are couting Balance ?

 ``12345`` ``````cout << "please create a Bank Acount" << endl; cin >>bAccount; cout << "\nYour bank balance is: " << "\$" << bAccount << "\n"; cout << "Please enter a wager - ";``````

This is gonna cout your bank account not the balance
Well, it suppose to be one of them. either balance or bank account. I think I messed up somewhere. What I am trying to do is have a bank account or balance at the beginning, when the player wins, add points to his/her account, when they lose subtract it from account/balance, and when they want to cash out, it should say how much money they have to go away with. But the other problem I don't know how to start with is when the player wants to play "hard way".

Thank you
Topic archived. No new replies allowed.