Home / Expert Answers / Computer Science / using-c-programming-in-visual-studio-answer-part-2-by-using-part1-note-when-developing-software-y-pa169

(Solved): Using c programming in visual studio answer part 2 by using part1 Note: When developing software, y ...



Using c programming in visual studio answer part 2 by using part1
Note: When developing software, you should always have fixed points in your development where you know your software is bug f
Stage 2
Add code to count how many times each die face value was rolled. Hint: Use an array in order to store this informatio
Note: When developing software, you should always have fixed points in your development where you know your software is bug free and runs correctly. Stage 1 Create an array to store the player's hand, i.e. the five dice values. For example: int player_hand ; Add code to simulate the rolling of five dice, i.e. deal the player's hand. That is, you should generate five random numbers, each in the range of 1 through 6 (inclusive) and assign each number to an array element. Use the rand() function (i.e. rand () ) to simulate the roll of a die. Hint: Use a loop in order to assign each random number (die roll) to an array element. Display the player's hand (i.e. the randomly generated dice roll) to the screen, e.g.: : " Place code to randomly generate the roll of five dice here.. */ Display player"s hand to the screen. */ printe ("lnlnPlayer"s hand:"); display_hand (player_hand, 5 ): Sample output (this will look different given we are generating random values here): Player hand: You may like to implement the void deal hand (int hand , int max_dice) function in this stage or you may prefer to wait until stage 10 (see stage 10 for function description). Make sure the program runs correctly. Once you have that working, back up your program. Note: When developing software, you should always have fixed points in your development where you know your software is bug free and runs correctly. Stage 2 Add code to count how many times each die face value was rolled. Hint: Use an array in order to store this information. To define an array in order to count how many times each die face value was rolled: int die_count ; Given that die face values are inclusive, we create an array with seven elements but ignore the zero element of the array. This will make it easier to increment the appropriate array element. That is, die_count[1] should contain the number of that were rolled, die_count[2] the number of rolled, etc. For example: In the example provided in stage 1, the player's hand is assigned the following dice values: . In light of this, the die_count should be as follows: To access and update the appropriate array element (using the value of the die as an index): int die_value = player_hand ; die_count:[die_value] - die_count[die_value] +1 : For example: If die_value is assigned the value 3. Hint: Use a loop in order to count how many times each die face value was rolled. In the example above, this would mean that player_hand[0] would then be player_hand[index] if placed within a loop.


We have an Answer from Expert

View Expert Answer

Expert Answer



This is related to computer programming, specifically using the C programming language in Visual Studio. It involves creating a program that simulates the rolling of five dice and displays the resulting numbers on the screen.

The program is broken down into two stages:

Stage 1:
In the first stage, the program creates an array to store the player's hand, which is the five dice values. The player's hand is then dealt by generating five random numbers, each in the range of 1 through 6 (inclusive) and assigning each number to an array element using a loop. The rand() function is used to simulate the roll of a die.
After the player's hand is dealt, the program displays the player's hand to the screen using the display_hand function. The display_hand function takes in the player's hand array and the number of dice (in this case, 5) as arguments and prints out the values of each die in the hand.

Stage 2:
In the second stage, the program adds code to count how many times each die face value was rolled. To do this, an array called die_count is defined to store the number of times each die value was rolled. The array has seven elements, one for each possible die face value (1-6 inclusive), but ignores the zero element.
The program then uses a loop to iterate through each die in the player's hand and updates the appropriate element in the die_count array based on the value of the die. For example, if the first die in the player's hand is a 3, the program updates the third element in the die_count array to indicate that a 3 was rolled. This process is repeated for each die in the hand.
Finally, the program displays the die count array to the screen, showing how many times each die value was rolled.
Overall, this program uses concepts such as arrays, loops, random number generation, and conditional statements to simulate the rolling of five dice and count the number of times each die value is rolled.
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe