I have this code that I started on but cant seem to finish it. i have to create an file and put the outcomes in it. I cant seem to figure it out. can soemone please help.
thanks,
john

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

using std::cout;
using std::cerr;
using std::cin;
using std::ios;
using std::endl;
using std::ofstream;
using std::ifstream;

void playCraps();
void reviewStatistics();
int rollDice();

int main()
{
   int choice;
   
   // continue game unless user chooses to quit
   do {
   
      // offer game options
      cout << "Choose an option" << endl
           << "1. Play a game of craps" << endl
           << "2. Review cumulative craps statistics" << endl
           << "3. Quit program" << endl;
           
      cin >> choice;
        
      if ( choice == 1 )
         playCraps();
      else if ( choice == 2 )
         reviewStatistics();

   } while ( choice != 3 );
   
   return 0;

} // end main

// review cumulative craps statistics
void reviewStatistics()
{
 [B]  /* Write a body for reviewStatistics which displays
      the total number of wins, losses and die rolls recorded 
      in craps.dat */ [/B] 

} // end function reviewStatistics
     
// play game
void playCraps()
{
   enum Status { CONTINUE, WON, LOST };
   int sum; 
   int myPoint;
   int rollCount = 0;
   Status gameStatus;
   
   ofstream outCrapfile("Craps.dat", ios::out);
   
   // seed random number generator and roll dice
   srand( time( 0 ) );
   sum = rollDice();
   rollCount++;
   
   // check game conditions
   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;

   } // end switch
   
   // keep rolling until player matches point or loses
   while ( gameStatus == CONTINUE ) { 
      sum = rollDice();
      rollCount++;
      
      if ( sum == myPoint )
         gameStatus = WON;

      else
         if ( sum == 7 )
            gameStatus = LOST;

   } // end while
   
   //  display status message and write results to file
   if ( gameStatus == WON ) {
      cout << "Player wins\n" << endl;
      /* Write player WIN status and the total number of die 
         rolls to a file */                  

   } // end if
   else {
      cout << "Player loses\n" << endl;
      [B]/* Write player LOSE status and the total number of die 
         rolls to a file */[/B] 

   } // end else

} // end function playCraps

// dice rolling function
int rollDice()
{
   int die1;
   int die2;
   int workSum;
   
   // roll two dice
   die1 = 1 + rand() % 6;
   die2 = 1 + rand() % 6;
   
   // total and print results
   workSum = die1 + die2;
   cout << "Player rolled " << die1 << " + " << die2
        << " = " << workSum << endl;
        
   return workSum;

} // end function rollDice

<< moderator edit: fixed [code][/code] tags >>

What problems are you having with it?

the bold parts. i need code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.