the second part of the blackjack program




//when the user didnt want one more card
if((res==2)||(res1==2)||(res2==2)||(tou3<=21))
{
//Dealer didnt need any card
//compare with non-added user
if(toc>16&&res==2)
{
cout<<"The dealer turns over his cards and has"<<com1<<"and"<<com2<<"("<<toc<<")\n";
cout<<"And you have"<<user1<<"and"<<user2<<"("<<tou<<")\n";
if (toc>tou)
{cout<<"Dealer win\n";}
else if (toc<tou)
{cout<<"You win\n";}
else if (toc==tou)
{cout<<"tie\n";}
}
//compare with added one card user
else if(toc>16&&res1==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"("<<toc<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"("<<tou1<<")\n";
if (toc>tou1)
{cout<<"Dealer win\n";}
else if (toc<tou1)
{cout<<"You win\n";}
else if (toc==tou1)
{cout<<"tie\n";}
}
//compare with added two cards user
else if(toc>16&&res2==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"("<<toc<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"("<<tou2<<")\n";
if (toc>tou2)
{cout<<"Dealer win\n";}
else if (toc<tou2)
{cout<<"You win\n";}
else if (toc==tou2)
{cout<<"tie\n";}
}
//compare with added three cards user
else if(toc>16&&tou3<=21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"("<<toc<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"and"<<user5<<"("<<tou3<<")\n";
if (toc>tou3)
{cout<<"Dealer win\n";}
else if (toc<tou3)
{cout<<"You win\n";}
else if (toc==tou3)
{cout<<"tie\n";}
}


//Dealer add one more card. 3 cards total
else if (toc<=16)
{
com3 = rand()%13+1;
toc1 = com1+com2+com3;
cout<<"Dealer add a card";
cout<<"Dealer:"<<com1<<"and"<<"X"<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"You:"<<user1<<"and"<<user2<<"("<<"("<<tou<<")\n";
//compare with non-added user
if(toc1>16&&res==2)
{
cout<<"The dealer turns over his cards and has"<<com1<<"and"<<com2<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"And you have"<<user1<<"and"<<user2<<"("<<tou<<")\n";
if (toc1>tou)
{cout<<"Dealer win\n";}
else if (toc1<tou)
{cout<<"You win\n";}
else if (toc1==tou)
{cout<<"tie\n";}
}
//compare with added one card user
else if(toc>16&&res1==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"("<<tou1<<")\n";
if (toc1>tou1)
{cout<<"Dealer win\n";}
else if (toc1<tou1)
{cout<<"You win\n";}
else if (toc1==tou1)
{cout<<"tie\n";}
}
//compare with added two cards user
else if(toc>16&&res2==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"("<<tou2<<")\n";
if (toc1>tou2)
{cout<<"Dealer win\n";}
else if (toc1<tou2)
{cout<<"You win\n";}
else if (toc1==tou2)
{cout<<"tie\n";}
}
//compare with added three cards user
else if(toc>16&&tou3<=21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"and"<<user5<<"("<<tou3<<")\n";
if (toc1>tou3)
{cout<<"Dealer win\n";}
else if (toc1<tou3)
{cout<<"You win\n";}
else if (toc1==tou3)
{cout<<"tie\n";}
}
//the dealer bust for adding one more card
else if (toc1>21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"("<<toc1<<")\n";
cout<<"Dealer bust\n";
cout<<"You win\n";
}
}


//Dealer add one more card 4 cards total
else if (toc1<=18)
{
com4 = rand()%13+1;
toc2 = com1+com2+com3+com4;
cout<<"Dealer add a card\n";
cout<<"Dealer:"<<com1<<"and"<<"X"<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"You:"<<user1<<"and"<<user2<<"("<<"("<<tou<<")\n";
//compare with non-added user
if(toc1>16&&res==2)
{
cout<<"The dealer turns over his cards and has"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"And you have"<<user1<<"and"<<user2<<"("<<tou<<")\n";
if (toc2>tou)
{cout<<"Dealer win\n";}
else if (toc2<tou)
{cout<<"You win\n";}
else if (toc2==tou)
{cout<<"tie\n";}
}
//compare with added one card user
else if(toc>16&&res1==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"("<<tou1<<")\n";
if (toc2>tou1)
{cout<<"Dealer win\n";}
else if (toc2<tou1)
{cout<<"You win\n";}
else if (toc2==tou1)
{cout<<"tie\n";}
}
//compare with added two cards user
else if(toc>16&&res2==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"("<<tou2<<")\n";
if (toc2>tou2)
{cout<<"Dealer win\n";}
else if (toc2<tou2)
{cout<<"You win\n";}
else if (toc2==tou2)
{cout<<"tie\n";}
}
//compare with added three cards user
else if(toc>16&&tou3<=21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"and"<<user5<<"("<<tou3<<")\n";
if (toc2>tou3)
{cout<<"Dealer win\n";}
else if (toc2<tou3)
{cout<<"You win\n";}
else if (toc2==tou3)
{cout<<"tie\n";}
}
//the dealer bust for adding two more card
else if (toc2>21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"("<<toc2<<")\n";
cout<<"Dealer bust\n";
cout<<"You win\n";
}
}


//Dealer add one more card 5 cards total
else if (toc2<=18)
{
com5 = rand()%13+1;
toc3 = com1+com2+com3+com4+com5;
cout<<"Dealer add a card\n";
cout<<"Dealer:"<<com1<<"and"<<"X"<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"You:"<<user1<<"and"<<user2<<"("<<"("<<tou<<")\n";
//compare with non-added user
if (toc3<=21&&res==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"("<<tou<<")\n";
if (toc3>tou)
{cout<<"Dealer win\n";}
else if (toc3<tou)
{cout<<"You win\n";}
else if (toc3==tou)
{cout<<"tie\n";}
}
//compare with added one cards user
else if (toc3<=21&&res1==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"("<<tou1<<")\n";
if (toc3>tou1)
{cout<<"Dealer win\n";}
else if (toc3<tou1)
{cout<<"You win\n";}
else if (toc3==tou1)
{cout<<"tie\n";}
}
//compare with added two cards user
else if (toc3<=21&&res2==2)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"And you have:"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"("<<tou2<<")\n";
if (toc3>tou2)
{cout<<"Dealer win\n";}
else if (toc3<tou2)
{cout<<"You win\n";}
else if (toc3==tou2)
{cout<<"tie\n";}
}
//the user didnt bust the 5th times and compare with dealer
else if (toc3<=21&&tou3<=21)
{
cout<<"Dealer has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"You have the card"<<user1<<"and"<<user2<<"and"<<user3<<"and"<<user4<<"and"<<user5<<"("<<tou3<<")\n";
if (toc3>tou3)
{cout<<"Dealer win\n";}
else if (toc3<tou3)
{cout<<"You win\n";}
else if (toc3==tou3)
{cout<<"tie\n";}
}
//the dealer bust for adding three more card
else if (toc3>21)
{
cout<<"The dealer turns over his cards and has:"<<com1<<"and"<<com2<<"and"<<com3<<"and"<<com4<<"and"<<com5<<"("<<toc3<<")\n";
cout<<"Dealer bust\n";
cout<<"You win\n";
}
}
}

switch(com1||com2||com3||com4||com5||user1||user2||user3||user4||user5)
{
case 1:
cout<<"A";
break;
case 10:
cout<<"T";
break;
case 11:
cout<<"J";
break;
case 12:
cout<<"Q";
case 13:
cout<<"K";
break;
default:
value=(char)(48+cardvalue);
break;
}
}
}
what are you trying to ask
Topic archived. No new replies allowed.