char handArray[2][1]={card1, card2};//creating an array which holds the two cards associated with a specific hand. Each card is represented by a single character
int cardValues[2]={0,0};//initializing an array that will hold the points associated with the two cards in the hand
for(int i =0; i <2; i++){//looping through the cards in the hand
switch(handArray[i][0]){//checking the card in the hand
case'T':
case'K':
case'Q':
case'J':
cardValues[i]=10;//if the card is 'T','K','Q' or 'J', then it is associated with a value of 10 points
break;
case'A':
if(i==1&& cardValues[0]==11){
cardValues[1]=1;//if the second card in the hand is an ACE and the first card was also an ACE, then the points associated with the second card is 1
}
else{
cardValues[i]=11;//if the card is an ACE but either (1) the first card in the hand, or (2) the second card in the hand, but first card was not ACE then points=11
}
break;
case'2':
case'3':
case'4':
case'5':
case'6':
case'7':
case'8':
case'9':
int cardValue2=handArray[i][0]-'0';//converting the card value from a character digit to an integer. To do this subtracting the ASCII value for '0' from the ASCII value from the character digit (e.g., '3') to return the ASCII value for the numeric digit (e.g. 3)
cardValues[i]=cardValue2;//after character digit has been converted to an integer, setting the appropriate value in the cardValues array equal to it
break;
};
};
int totalPoints=cardValues[0]+cardValues[1];//calculating total points
if(cardValues[0]==0| cardValues[1]==0){
printf("There was an invalid card in the hand. Caution should be applied when interpreting the total points calculation.");
};
return totalPoints;
};
int main(){
int totalPoints= blackJackValue('Z','4');
printf("Total Points Associated with Hand: %i\n", totalPoints);