CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: I need help with this program!!

  1. #1
    Join Date
    Mar 2009

    Angry 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;


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

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

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


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

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

    Can anyone help me out?!

  2. #2
    Join Date
    Sep 2004
    Holland (land of the dope)

    Re: I need help with this program!!

  3. #3
    Join Date
    Jun 2002
    Stockholm, Sweden

    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.
    Nobody cares how it works as long as it works

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003

    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?

Tags for this Thread

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)