Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. // program to determine value including aces.
  2. #include <iostream>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. //function prototype
  7.  
  8.  
  9. int showValue(int (&array1)[10], int &totalVal)
  10. {
  11. int i = 0;
  12. int cards[10]; //array
  13. //int totalVal;
  14. char aces;
  15. int numOfAces;
  16.  
  17.  
  18. while (cards[i] > 1 && cards[i] <= 10) // validate. if any slot has an invalid # the program ends. doesnt cout anything
  19. {
  20. // if statement for aces.
  21. if (cards [i] <= 21)
  22. {
  23. cout << "Are there any aces? Enter y or n" << endl;
  24. cin >> aces;
  25. }
  26.  
  27. if(aces == 'n') // if no aces simply return value in accumulator
  28. {
  29. return totalVal;
  30. }
  31.  
  32. else if (aces == 'y') // aces
  33. {
  34. cout << "How many? " << endl;
  35. cin >> numOfAces;
  36.  
  37. if (numOfAces >= 1 && totalVal > 21) // 1 or more aces and soft hand
  38. {
  39. totalVal = totalVal - 10;
  40. return totalVal;
  41. }
  42.  
  43. /*else if (numOfAces == 1 && totalVal > 21); // hard hand ace = 1 return total value
  44. {
  45. totalVal = totalVal - 10;
  46. return totalVal;
  47. }*/
  48. }
  49. } // end of if aces
  50. }
  51.  
  52. void main()
  53. {
  54. int array1[10] = (5,8,11);
  55. int totalVal;
  56. //int cards;
  57. showValue(array1, totalVal);
  58. //cout << "" << cards << "" << totalVal << endl;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement