Code:
#include <iostream.h>
#include <string>
#include <time.h>
#include <cstdlib>
#include <stdlib.h>
//=============================================================
int PlayerCardA=0;//PLAYER CARD 1
int PlayerCardB=0;//PLAYER CARD 2
int PlayerTotal=0;//PLAYER TOTAL
int ComputerCardA=0;//COMPUTER CARD 1
int ComputerCardB=0;//COMPUTER CARD 2
int ComputerTotal=0;//COMPUTER TOTAL
int Bank=1000;//BANK
int xWager=0;//WAGER
int xNewCard=0;//NEW CARD
bool xSync=true; //SYNC TRUE?
bool xHit_Stay=false; //HIT OR STAY?
//=============================================================
void PlayerCards(int& A, int& B);//PLAYER CARDS
void ComputerCards(int& A, int& B);//COMPUTER CARDS
int Wager(int& A);//WAGER
int NewCard();//NEW CARD
void Winner(bool& A, bool& B, bool& C);//WINNER
int Display(int A, int B, int C, int D, int& E, int& F);//DISPLAY CARDS
bool Hit_Stay();//HIT OR STAY
//=============================================================
int main(void)
{
srand(time(NULL));
cout<<"Welcome to Black Jack. You have $1000 in the bank.\n\n";
cout<<"------------------------------------------------------";
cout<<"\nPress enter to continue...";
cin.get();
system("cls");
do
{
xWager = Wager(xWager); //CALL WAGER FUNCTION
PlayerCards(PlayerCardA,PlayerCardB);//GENERATE PLAYER CARDS
ComputerCards(ComputerCardA,ComputerCardB);//GENERATE COMPUTER CARDS
Display(PlayerCardA,PlayerCardB,ComputerCardA,ComputerCardB,PlayerTotal,ComputerTotal);//DISPLAY TOTALS
}
while(xSync == true);
return(0);
}
//=============================================================
int Wager(int& A)
{
cout<<"Please enter your wager:$"; //REQUEST WAGER
cin>>xWager; //GET WAGER
system("cls");
return(A);
}
//=============================================================
void PlayerCards(int& A, int& B)
{
A = 2 + (rand() % (14 - 2 + 1));
B = 2 + (rand() % (14 - 2 + 1));
}
//=============================================================
void ComputerCards(int& A, int& B)
{
A = 2 + (rand() % (14 - 2 + 1));
B = 2 + (rand() % (14 - 2 + 1));
}
//=============================================================
int Display(int A, int B, int C, int D, int& E, int& F)
{
string CardA = "boo";
string CardB = "bee";
string CardC = "baa";
string CardD = "bum";
//=====================
E = A+B; // PLAYER TOTAL = PLAYERTOTALA+PLAYERTOTALB
F = C+D; // COMPUTER TOTAL = COMPUTERCARDA+COMPUTERCARDB
cout<<"You drew a "<< CardA << " and a "<< CardB <<" for a total of " << E <<".\n";
cout<<"The computer drew a "<< CardC << " and a "<< CardD <<" for a total of "<< F <<".\n";
cout<<"\nPress enter to continue...";
cin.get();
system("cls");
return(0);
}