Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // program to determine value including aces.
- #include <iostream>
- #include <iomanip>
- using namespace std;
- //function prototype
- int showValue(int (&array1)[10], int &totalVal)
- {
- int i = 0;
- int cards[10]; //array
- //int totalVal;
- char aces;
- int numOfAces;
- while (cards[i] > 1 && cards[i] <= 10) // validate. if any slot has an invalid # the program ends. doesnt cout anything
- {
- // if statement for aces.
- if (cards [i] <= 21)
- {
- cout << "Are there any aces? Enter y or n" << endl;
- cin >> aces;
- }
- if(aces == 'n') // if no aces simply return value in accumulator
- {
- return totalVal;
- }
- else if (aces == 'y') // aces
- {
- cout << "How many? " << endl;
- cin >> numOfAces;
- if (numOfAces >= 1 && totalVal > 21) // 1 or more aces and soft hand
- {
- totalVal = totalVal - 10;
- return totalVal;
- }
- /*else if (numOfAces == 1 && totalVal > 21); // hard hand ace = 1 return total value
- {
- totalVal = totalVal - 10;
- return totalVal;
- }*/
- }
- } // end of if aces
- }
- void main()
- {
- int array1[10] = (5,8,11);
- int totalVal;
- //int cards;
- showValue(array1, totalVal);
- //cout << "" << cards << "" << totalVal << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement