Image

Imagetransmogrify wrote in Imagecpp

craps game

i'm working on this assignment to program a game of craps. i need to insert a forloop to make the dice roll 10 times and output all 10 results. my brain isn't functioning and i'm getting really frustrated over this. please help and let me know what i screwed up here.

#include <iostream.h>
#include <stdlib.h>

int  main()
  {
    int score1 = 0, score2 = 0, rollnumber= 1;
    int n1, n2, n3, n4;

    srand (0);

    n1 = (rand () % 6) + 1;
    n2 = (rand () % 6) + 1;

    score1 = n1 + n2;

    switch (score1)
     {
       case 7:
       case 11:  cout << " Congratulations! " << endl;
                 cout << " Your roll was: " << score1 << endl;
                 cout << " You win on the first roll " << endl;
                 break;
       case 2:
       case 3:
       case 12:  cout << " Sorry ....." << endl;
                 cout << " Your roll was: " << score1 << endl;
                 cout << " You lose on the first roll " << endl;
                 break;
       case 4:
       case 5:
       case 6:
       case 8:
       case 9:
       case 10:  cout << " You rolled a " << score1 << endl;
                 cout << " You get another roll " << endl;
                 

                 while ((score2 != 7) && (score2 != score1))
                  {
                   n3 = (rand () % 6) + 1;
                   n4 = (rand () % 6) + 1;
                   score2 = n3 + n4;
                   cout << "for rollnumber " << ++rollnumber 
                        << " you rolled: " << score2 << endl;
                  }

                 if (score2 == 7) {
                                   cout << " You last rolled a SEVEN " << endl;
                                   cout << " Sorry You lose " << endl;
                                  }
                 else
                    {
                     cout << " Your last roll was a: " << score2 << endl;
                     cout << " You win by matching your first roll" << endl;
                    }
       }
    return 0;     
  }