Need help for a program that scores a blackjack hand

My assignment is to write a program that scores a blackjack hand. all the cards from 2-9 are scored as 2-9 points, while 10,j,q,k, are 10 points, and ace has 1 or 11 points. My program runs fine for cards that are 2-9, however, when I input jack, queen, king, or ace, it gives out very weird output (program goes into infinite loop saying my hand is busted). I am wondering what went wrong with my code and what is the best way to fix it? (I think it has something to do with int types_of_cards, because it only read int type, so when I type 'jack' it does not read, but i am not sure how i can fix it).

Thank you very much in advance!!

#include <iostream>
using namespace std;

int main()
{
/* Write a program that calculate score for a hand of blackjack.
I will ask how many cards the player has, and ask the user to
type in each of the card that he has.
After that, each card is assigned a value, 2-9 for 2-9 score, and
t, j, q, k, have scores of 10 and a has score of 1 or 11
Convert the card into numerical values, and sum up the value
for the user. if the value is greater than 21, say busted. if
the value is less than or equal to 21, display that value. (if.else)
ask if the player like to continue with the next hand.
*/
int jack, queen, king;
jack = queen = king = 10;
int ace;
ace = 11;
int number_of_cards;
int types_of_cards;
char next_set, y, Y;
int sub_total = 0;

//How do I set a, j,q,k to numeric value?

do
{
cout << "How many cards do you have? ";
cin >> number_of_cards;
cout << "please enter what cards you have ";

do
{
cin >> types_of_cards;
number_of_cards--;
sub_total = sub_total + types_of_cards;
}while (number_of_cards > 0);


if (sub_total <= 21)
{
cout << "The value of your hand is " << sub_total << "\n"; }
else
cout << "your hand is busted.\n";


cout << "Would you like to calculate another set? ";
sub_total = sub_total - sub_total;
cin >> next_set;

}while ((next_set == 'y') || (next_set == 'Y'));

cout << "thank you for using this program \n ";

return 0;
}
Topic archived. No new replies allowed.