CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: I need help with this program!!

1. Junior Member
Join Date
Mar 2009
Posts
1

## I need help with this program!!

I have a program that I need to modify but I am stuck. Here are the terms.

- Modify the program by inserting a big part into a loop that will play the program over and over and will display a number of times you have played the game.

- Have the program ask you how many times you want to play the game.
- Then the program will play the game the number of times you request.
- Keeping track of the number of times there was a win or loss.
- Have the program display the percent (%) of times there was a win.
- The answer should be a little under 50% (about 47%).

Here is the sample program that I have to go off to include these stipulations above.

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

int rolldice ();

void main ()
{
enum Status {CONTINUE, WON, LOST};
int Sum, MyPoint;
Status GameStatus;

srand(time(0));

//Roll the dice
Sum = rolldice();
cout << "You rolled " << Sum << '.' << endl;

switch (Sum)
{
case 7:
case 11:
GameStatus = WON;
break;
case 2:
case 3:
case 12:
GameStatus = LOST;
break;
default:
GameStatus = CONTINUE;
MyPoint = Sum;
cout << "Point is " << MyPoint << '.' << endl;
break;
}

while (GameStatus == CONTINUE)
{
Sum = rolldice();
cout << "The roll is " << Sum << '.' << endl;
if (Sum == MyPoint)
GameStatus = WON;
else
if (Sum == 7)
GameStatus = LOST;

}

if (GameStatus == WON)
cout << "You win the game." << endl;
else
cout << "You lose the game." << endl;
}

int rolldice ()
{
int Die1, Die2;
int Total;
Die1 = (rand() % 6) +1;
Die2 = (rand() % 6) +1;
Total = Die1 + Die2;
}

Can anyone help me out?!

2. ## Re: I need help with this program!!

3. Senior Member
Join Date
Jun 2002
Location
Stockholm, Sweden
Posts
1,641

## Re: I need help with this program!!

You chose an angry face icon for this thread...

Exactly what are you angry at? Is it your own noobness maybe

If you want to learn programming, being angry is the worst possible starting point.

4. Elite Member Power Poster
Join Date
Nov 2003
Location
Florida
Posts
12,560

## Re: I need help with this program!!

"Have the program ask you how many times you want to play the game. "

Can you do that?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

Click Here to Expand Forum to Full Width