### BlackJack

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194`` ``````#include using namespace std; int main () { char cards, repeat = 'N'; int number_of_cards; int total_card_value = 0; int card_value = 0; int card_value1 = 0; int card_hand = 0; int aces = 0; int counter = 0; // Ask the user how many cards she or he has: cout << "Welcome to the program blackjack!" << endl; cout << "The program consists of the following: a player receives from two to five cards" << endl; cout << "The face cards- jack, queen, and king are scored as 10 points. The goal is" << endl; cout << "to come as close to a score of 21 as possible without going over 21." << endl; cout << "How many cards do you have? \n " ; cin >> number_of_cards; cout << endl; // Input characters representing the cards that is, 2, 3, 4, or 5. // Using a for loop: { for (card_hand = 2 ; card_hand <= 5; card_hand++) cout << " What are the card values? " << endl; cin >> cards; counter ++; switch (cards) { case '2': card_value = card_value + 2; card_value1 = card_value + 2; break; case '3': card_value = card_value + 3; card_value1 = card_value + 3; break; case '4': card_value = card_value + 4; card_value1 = card_value + 4; break; case '5': card_value = card_value + 5; card_value1 = card_value + 5; break; case '6': card_value = card_value + 6; card_value1 = card_value + 6; break; case '7': card_value = card_value + 7; card_value1 = card_value + 7; break; case '8': card_value = card_value + 8; card_value1 = card_value + 8; break; case '9': card_value = card_value + 9; card_value1 = card_value + 9; break; case 'T': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'J': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'Q': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'K': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'A': card_value = card_value + 10; card_value1 = card_value + 10; break; case 't': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'j': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'q': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'k': card_value = card_value + 10; card_value1 = card_value + 10; break; case 'a': card_value = card_value + 10; card_value1 = card_value + 10; break; // Use a while loop to take care of aces. } { while (aces > 0) { if (total_card_value <= 10) total_card_value = total_card_value + 11; else if (total_card_value > 10) total_card_value = total_card_value + 1; aces --; } if (total_card_value < 21) { cout << " Your total score is: " << total_card_value << endl; } else if (total_card_value = 21) { cout << " Very well."; cout << "Your total score is: " << total_card_value << endl; } else if (total_card_value > 21) { cout << "BUSTED! \n"; cout << "Your score: " << total_card_value << endl; } cout << " Do you want to repeat? Yes or No? \n"; cin >> repeat; // While loop to let the user repeat the calculation: } while ((repeat == 'Y') || (repeat == 'y')); } cout << endl; return 0; } ``````
Uhm?
Oh sorry, I just needed to show someone my code. I sent them the link.
http://ideone.com/

Shows the workings code! (:
I have never heard of that site before, thank you so much!
No problem. (:
Also, if you and a friend want to code at the same time, on the same project:
http://collabedit.com/
You are so nice, thank you very much!
Again, no problem! lol (:
I may seem like a stalker but your webpage https://sites.google.com/site/davevisone/ is wonderful! I hope someday to be as good as you!
ahaha thanks! You should aspire to be better! Never settle for "As good..." lol!

Cause I could be better, and I should be! (:
You're welcome! Such great advice! I wish you all the luck and once again, thank you! :))
lol, thanks. You too! (:
Topic archived. No new replies allowed.