rendered paste body/* * p4.cpp * Contains the main function * * Assignment 4, Craps * SID: 995050550 * Author: Crystal Tse * Due: February 17, 2009 * Class: ECS 40, Winter 2009 */#include <iostream>#include <fstream>using namespace std;#include "Craps.h"#include "Player.h"#include "Dice.h"int main() { Craps c1, c2; ofstream Player1Data, Player2Data; int numGames = 10000, numTotalWins = 0, numWinsOnFirst = 0, numLossesOnFirst = 0; Player1Data.open("Play1D.txt"); // creates or opens a file called Play1D.txt Player1Data<<"Games Played \t Money"<<endl; // same syntax as cout for(int i=0; i<numGames; i++) // betting $1 each time { c1.collectBet('A'); c1.play(); Player1Data << c1.getNumberOfGame() << " \t " << c1.getPlayersMoney() << endl; } Player1Data.close(); numTotalWins += c1.gameWins(); numWinsOnFirst += c1.winsOnFirstRoll(); numLossesOnFirst += c1.lossesOnFirstRoll(); c1.getDiceProbability(); Player2Data.open("Play2D.txt"); // creates or opens a file called Play2D.txt Player2Data<<"Games Played \t Money"<<endl; // same syntax as cout for(int i=0; i<numGames; i++) // betting doubles each time { c2.collectBet('B'); c2.play(); Player2Data << c2.getNumberOfGame() << " \t " << c2.getPlayersMoney() << endl; } Player2Data.close(); numTotalWins += c2.gameWins(); numWinsOnFirst += c2.winsOnFirstRoll(); numLossesOnFirst += c2.lossesOnFirstRoll(); cout << "1. Approximate probability of winning the game: " << (double)numTotalWins/(numGames*2) * 100 << "%" << endl; cout << "2. Approximate probability of winning on first roll: " << (double)numWinsOnFirst/(numGames*2) * 100 << "%" << endl; cout << "3. Approximate probability of losing on first roll: " << (double)numLossesOnFirst/(numGames*2) * 100 << "%" << endl; return 0;}