All pastes #1852428 Raw Edit

PA 6 Pgm 1

public text v1 · immutable
#1852428 ·published 2010-03-26 01:07 UTC
rendered paste body
//PA6 Pgm 1
//Udit Meghraj
// March 24

#include <iostream.h>
#include "math.h"
#include "randgen.h"
#include "apstring.h"

void main()
{
  int points = 30, bet = 5;
  int choice = 0;
  int roll1, roll2, sum, target;


  cout<<"Beat The House Roller!"<<endl;
  while (points > 0)
  {
     cout<<"points = " << points<<endl;
     cout<<"(0) quit or (1) bet? ";
     cin>>choice;
     if (choice == 1) 
	{
        cout<<"how much? ";
        cin>>bet;
        while((bet % 5 != 0) || (bet < 0) || (bet > 50))
         {
           cout<<"illegal bet--please bet again:" << endl;
           cout<<"how much? ";
           cin>>bet;
        }

        roll1 = 0;
        roll2 = 0;
        target = roll1 + roll2;

        cout<<"opening roll: " << roll1 << " + " << roll2 << " = "<< target<<endl;
        if ((target == 2) || (target == 3) || (target == 12))
         {
           cout << "loser!" << endl;
           points - = bet;
           cout<<"continue"<<endl;
        } 
        else 
        if((target == 7) || (target == 11)) 
        {
           cout << "winner!" << endl;
           points += bet;
           cout<<"continue"<<endl;
        }

        sum = 0;

        while((sum != 7) && (sum != target))
         {
           roll1 = 0;
           roll2 = 0;
           sum = roll1 + roll2;
           cout<<"roll: " << roll1 << " + " << roll2 << " = " << sum << endl;
           if(sum == 7) {
              cout << "you lose!" << endl;
              points -= bet;
              cout<<"continue"<<endl;
           } 
           else 
           {
              cout<<"you win!" << endl;
              points + = bet;
           }
        }
     } 
     else
        cout<<"0"<<endl;
  }
  if (points <= 0)
     cout<<"busted!"<<endl;
  cout<<"0"<<endl;
}