NEED HELP FAST(CRAPS PROGRAM)

I cannot figure this program out. My teacher gave us a template to complete this program, but it's confusing and I have no time to go through it with him. Bad thing is, the program is due tomorrow. PLEASE HELP! This is what I have so far.




#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include "rolldice.cpp"

using namespace std;

int main()
{

const int LUCKY_SEVEN = 7,
CRAPS = 7,
YO_LEVEN = 11,
SNAKE_EYES = 2,
TREY = 3,
BOX_CARS = 12;

const double MINIMUM = 500.00;

int die1, die2, dieSum, point;
double purse, bet;
bool out_of_money, won, quit, lose;
char response;
ofstream outs;

void rolldice(int& die1, int& die2);

cout<<"This program is to play the game of craps. You will start with a\n"
<<"$500 purse. You will be prompted to bet each time before each dice\n"
<<"roll. If your rolls equal 11 or 7 on your first roll, you win. If you\n"
<<"roll Snake Eyes, Trey, or Box Cars, you lose. Any other conbination,\n"
<<"that amount becomes your point and you will continue to roll. The\n"
<<"program will recognize an illegal bet and prompt you to enter a valid\n"
<<" bet. Until you do, the program will continue to prompt\n"
<<"you. If you out of money, the program will ask if you wish to restart\n"
<<"the program and play again.\n";




outs.open("craps.txt");

//Prompt for and read the amount of money in the purse. You complete the code




if(purse<MINIMUM)
{
cout<<"Out of money.Come back when have enough money to play.\n";
outs<<"Out of money.Come back when have enough money to play.\n";
}
else
//Play craps
do
{
cout<<"You are starting with $"<<MINIMUM<<" in your purse.\n";
outs<<"You are starting with $"<<MINIMUM<<" in your purse.\n";
do
{
cout<<"Please enter your bet now:\n";
outs<<"Please enter your bet now:\n";
cin>>bet;

if(bet<=0)
{
cout<<"Invalid bet. Please re-enter bet now:\n";
outs<<"Invalid bet. Please re-enter bet now:\n";






//Error check purse value and send appropriate message
//You complete the code, allowing user to re-enter bet until he/she
//places a valid value for the bet.





}while(bet>0);//You need to determine the condition!

//Roll the dice!

cout<<"\n\nRoll the dice!\n";
system("PAUSE");
rolldice(die1,die2);
dieSum = die1 + die2;

//Inform player about what they rolled. You provide the code.
cout<<"You rolled a"<<dieSum<<"\n";
cout<<"The first die was a"<<die1<<"\n";
cout<<"The second die was a"<<die2<<"\n";





switch(dieSum)
{
case LUCKY_SEVEN: won = true;
case YO_LEVEN: won = true;
break;
case SNAKE_EYES: lose = true;
case TREY: lose = true;
case BOX_CARS: won = false;
break;
default: point = dieSum;
//Inform player that what they rolled becomes their point





do
{
cout<<"\n\nRoll the dice!\n";
system("PAUSE");
rolldice(die1,die2);
dieSum = die1 + die2;
//Repeat code to roll the dice and inform user of result of roll
//You provide the code.



}while(dieSum not point and not crap out);
//You need to determine what the condition is.

//Set won to true or false depending on outcome of dieSum
//You write the code.



} //end of switch

if(won)
{
cout<<"Congratulations! You won $"<<
//Congratulate player and adjust purse appropriately. You write the code.





}
else
{
//Inform player of loss and why!! You write the code!




}

if(purse>0)
{
out_of_money = false;

cout<<"You have $"<<purse<<" after your last roll.\n";

//Inform player of updated amount in purse. You write the code.





do
{
cout<<"Would you like to play again?\n";
cin>>response;
response = toupper(response);
if(response !='Y' && response != 'N')
cout<<"Illegal response! Please answer Y for Yes or N for No!\n";
}while(response != 'Y' && response != 'N');
if(response=='N')
quit = true;
else
quit = false;
}
else
{
cout<<"You have no money. Come back when you have sufficient funds.\n";







}
}while(condition for not quiting and not out of money);//You determine condition

cout<<"You come back soon now!\n";
outs<<"You come back soon now!\n";
system("PAUSE");
outs.close();
return 0;
}

Last edited on
Topic archived. No new replies allowed.