1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
#include <iostream>
using namespace std;
const int two = 2, three = 3, four = 4, five = 5, six = 6, seven = 7, eight = 8, nine = 9, ten = 10, jack = 10, queen = 10, king = 10;
int main()
{
char cont_program = 'n', card_1, card_2, card_3, card_4, card_5;
int cards_in_hand, hand_count, count_two = 0, count_three = 0, count_four = 0, count_five = 0, count_six = 0, count_seven = 0,
count_eight = 0, count_nine = 0, count_ten = 0, count_jack = 0, count_queen = 0, count_king = 0, count_ace = 0, ace;
do
{
cout << "Hello!\n";
cout << "This program will allow you to find your card score in a game of blackjack.\n\n";
cout << "How many cards do you have in your hand (2, 3, 4, or 5)?\n";
cin >> cards_in_hand;
cout << "\n\nEnter numbers 1 through 9 for those respective cards and the following for the others:\n";
cout << "T = 10, J = Jack, Q = Queen, K = King, A = Ace\n\n";
//Note: the '10' card is input as 't' or 'T'.
if (cards_in_hand == 2)
{
cout << "What are your ";
cout << cards_in_hand;
cout << " cards?\n";
switch (card_1)
{
case '2':
count_two++;
break;
case '3':
count_three++;
break;
case '4':
count_four++;
break;
case '5':
count_five++;
break;
case '6':
count_six++;
break;
case '7':
count_seven++;
break;
case '8':
count_eight++;
break;
case '9':
count_nine++;
break;
case 't':
case 'T':
count_ten++;
break;
case 'j':
case 'J':
count_jack++;
break;
case 'q':
case 'Q':
count_queen++;
break;
case 'k':
case 'K':
count_king++;
break;
case 'a':
case 'A':
count_ace++;
break;
}
switch (card_2)
{
case '2':
count_two++;
break;
case '3':
count_three++;
break;
case '4':
count_four++;
break;
case '5':
count_five++;
break;
case '6':
count_six++;
break;
case '7':
count_seven++;
break;
case '8':
count_eight++;
break;
case '9':
count_nine++;
break;
case 't':
case 'T':
count_ten++;
break;
case 'j':
case 'J':
count_jack++;
break;
case 'q':
case 'Q':
count_queen++;
break;
case 'k':
case 'K':
count_king++;
break;
case 'a':
case 'A':
count_ace++;
break;
}
}
//The code continues from here, getting another switch for each cards_in_hand value possible
|