Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You will start organizing your code into functions. You will start by moving the

ID: 3729020 • Letter: Y

Question

You will start organizing your code into functions. You will start by moving the central part of your code into a main function, if you have not already. This function will mainly have a loop that executes until the user enters the option to You will create a value-returning function with all the code that displays the menu and makes sure the user entered a valid choice. This new menu function will not take any input, but will pass back to the calling function a valid menu choice. (Remember that program input and output is not the same thing as function input and output. Function input is what is passed in on the parameter list, NOT reading data from the keyboard. Function output is anything returned to the calling function whether it is on the parameter list or in a return statement.) You will move the code to display the face value of a card into a new function called display face value. This function will take as input one numeric card value. The function will then display the one word face value of the card passed in. This function will not pass back anything to the calling function. Pay attention to the words in bold and follow the directions. I have reasons for having you do this a specific Adding a new option to your menu (3. Deal Hand). you will now have the following options: 1. Make Change 2. High Card 3. Deal Hand 4. Quit Make Change and High Card will now be moved into their own functions. So, if the user enters option 1, your main will call make_change0. If the user enters option 2, your main will call high_ cardo. When chosen, option 3 will call the deal hand function. This function will generate, or "deal" an entire 5-card hand. You will declare 5 new variables, one for each card in a 5-card hand. Once all 5 cards have been dealt, display the face value for each of the cards in the hand. You will use your new display_face_value function to do this. You will have to call it once for each card. Again, I have reasons for having you do this a specific way, so be sure you follow the Only have the functions as directed in the assignment.

Explanation / Answer

Please mention the language of your preference. For time being, I am providing the code in C++.

CODE

======================

// this array represents whether a card in a deck is dealt or not.
// A value of 0 indicates that the card is not dealt, 1 means card already dealt.
// You need to define this array inside main().
int *is_dealt = new int[52];

// initially set is_dealt to 0 for all indices
for(int i=0; i<52; i++) {
is_dealt[i] = 0;
}

// here, pass is_dealt[] to deal_hand()
void deal_hand(int *is_dealt) {
// In this method, we will generate five random numbers which represents five cards dealt.
int card1, card2, card3, card4, card5;
  
// loop to pick up 1st random card
while(true) {
card1 = rand() % 52;
// if the card is not already dealt, break out of the loop, else continue
if(!is_dealt[card1])
break;
}
  
// loop to pick up 2nd random card
while(true) {
card2 = rand() % 52;
// if the card is not already dealt, break out of the loop, else continue
if(!is_dealt[card2])
break;
}
  
// loop to pick up 3rd random card
while(true) {
card3 = rand() % 52;
// if the card is not already dealt, break out of the loop, else continue
if(!is_dealt[card3])
break;
}
  
// loop to pick up 4th random card
while(true) {
card4 = rand() % 52;
// if the card is not already dealt, break out of the loop, else continue
if(!is_dealt[card4])
break;
}
  
// loop to pick up 5th random card
while(true) {
card5 = rand() % 52;
// if the card is not already dealt, break out of the loop, else continue
if(!is_dealt[card5])
break;
}
  
// now, we need to set the is_dealt[] to 1 for the five random picked cards
is_dealt[card1] = 1;
is_dealt[card2] = 1;
is_dealt[card3] = 1;
is_dealt[card4] = 1;
is_dealt[card5] = 1;
  
// display all the cards
display_face_value(card1);
display_face_value(card2);
display_face_value(card3);
display_face_value(card4);
display_face_value(card5);
}

**NOTE: Please provide the exisiting code that you had already implemented so that I can refer to it and provide you a more exact implementation of deal_hand().

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote