rodeostar04 -1 Newbie Poster

I would appreciate if anyone could help me with my program that calculates a hand of black jack. I know the way I created this program is probably not the most effective way but the only thing I seem to have problems with is getting the program to add 10 when a user enters King, Queen, or Jack so that is what I need the most help with. I would appreciate any other tips. The only requirements for this program is to use a Switch Case statement. Here is my code. Thank you in advanced for any help.

#include <cstdlib>
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char *argv[])
{
/* Declare variables*/
int card1, card2, card3, hand, sum23, sum13, sum21, value1, value2, value3, 
cardentered1;
char King, Queen, Jack;

/* Get information from user*/
cout<<"Enter the value of your first card: ";
cin>>cardentered1;
cout<<"Enter the value of your second card: ";
cin>>card2;
cout<<"Enter the value of your third card: ";
cin>>card3; 


/* Display hand total*/
if (cardentered1==King || cardentered1==Queen ||cardentered1==Jack)
card1=10;
else 
card1=cardentered1;

if (cardentered2==King || cardentered2==Queen ||cardentered2==Jack)
card2=10;
else 
card2=cardentered2;

if (cardentered3==King || cardentered3==Queen ||cardentered3==Jack)
card3=10;
else 
card3=cardentered1;

sum23=card2+card3;
sum13=card1+card3;
sum21=card2+card1;

switch (card1)
{
case 1:
if (sum23<=10)
value1=11;
else
value1=1;
break;
case 2:
value1=2;
break;
case 3:
value1=3;
break;
case 4:
value1=4;
break;
case 5:
value1=5;
break;
case 6:
value1=6;
break;
case 7:
value1=7;
break;
case 8:
value1=8;
break;
case 9:
value1=9;
break;
case 10:
value1=10;
break;
}

switch (card2)
{
case 1:
if (sum13<=10)
value2=11;
else
value2=1;
break;
case 2:
value2=2;
break;
case 3:
value2=3;
break;
case 4:
value2=4;
break;
case 5:
value2=5;
break;
case 6:
value2=6;
break;
case 7:
value2=7;
break;
case 8:
value2=8;
break;
case 9:
value2=9;
break;
}

switch (card3)
{
case 1:
if (sum21<=10)
value3=11;
else
value3=1;
break;
case 2:
value3=2;
break;
case 3:
value3=3;
break;
case 4:
value3=4;
break;
case 5:
value3=5;
break;
case 6:
value3=6;
break;
case 7:
value3=7;
break;
case 8:
value3=8;
break;
case 9:
value3=9;
break;
}

hand=value1+value2+value3;
if (hand<21)
cout<<"You only have "<<hand<<" this is not enough"<<endl;
else if (hand>21)
cout<<"Your hand is "<<hand<<" this is to much"<<endl;
else
cout<<"You win!!! Your hand equals 21!!!!"<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.