Wrong!!
Wrong!!
(int & point) { point = ThrowDice(); if ((point==7)||(point==11)) { cout <<"Player wins!"; point = -1; return true; } else if((point==2)||(point==3)||(point==12)) { cout << "Player loses!"; point = -1; return true; } else { cout << "Point value is " << point <<endl; return false; a = ThrowDice(); }while (!((a==7)||(a==point))); if (a==7) cout << "Player loses!"; else cout << "Player wins!"; } return 0; } } }
int main() { int point=0; bool End = OpeningRoll(point); if ( End ) { return 0; } else { int a; do{
int RollOneDie() { int random; cout << "Please enter an integer in the range of 1 to 6\n"; cin >> random; return random; } int ThrowDice() { int x,y,z; x= RollOneDie(); y= RollOneDie(); z= x + y; cout << "Player roll "<< x << "+" << y << "=" << z << endl; return z; }
WRONG!!
#include <iostream> #include <iomanip> using namespace std; int RollOneDie(); int ThrowDice(); bool OpeningRoll(int& );
{ return 0; } else { int a; do{ a = ThrowDice(); }while (!((a==7)||(a==sum))); if (a==7) cout << "Player loses!"; else cout << "Player wins!"; } return 0; } bool OpeningRoll (int & point) { int sum = ThrowDice(); if ((sum==7)||(sum==11)) { cout <<"Player wins!"; point = -1; return true; } else if ((sum==2)||(sum==3)||(sum==12)) { cout << "Player loses!"; point = -1; return true; } else { cout << "Point value is " << sum int RollOneDie() { int random; cout << "Please enter an integer in the range of 1 to 6\n"; cin >> random; return random; } <<endl; return false; } }
int ThrowDice() { int x,y,z; x= RollOneDie(); y= RollOneDie(); z= x + y; cout << "Player roll "<< x << "+" << y << "=" << z << endl; return z; }