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

Here is my Question: Rules for our Drop Dead Game (2 person game): 1. Use a text

ID: 3600140 • Letter: H

Question

Here is my Question:

Rules for our Drop Dead Game (2 person game):
1. Use a textbox on the form to determine the goal for the game. For example, the goal may be to earn 100 points. Use a KeyPress event for this textbox to restrict the data entry to digits, backspace, etc.

2. Player 1 takes a turn rolling 5 die (you will not need the 6th die from the Roll ‘Em chapter example)

Example: Bob rolls 5 die with these results: 4-6-3-1-4

3. If any of the 5 dice rolled includes a 6, Player 1 earns no points for that roll and Player 1’s turn ends.   Otherwise, the score for Player 1 is the total of the face values on the die and Player 1 rolls again. This continues (rolling and adding points) until Player 1 rolls a 6.

Example: Bob points = 4+5+3+1+4 = 17

These points are added to Bob’s total and Bob rolls again.

HINT: A loop can be used to roll dice until 6 is rolled.

4. Player 2 follows the same rules.

5. The first player to reach the goal wins.

6. Display the winner of the game.  

7. Allow the players to restart the game and play again.

Explanation / Answer

CODE IN C:

#include<stdio.h>
#include<stdlib.h>
main(){
   int player1,player2,turn,dice,option;
   printf(" ****Game start****");
   player1=0;
   player2=0;
   turn=0;
   while(1){
       if(turn==0){
           printf(" Player1 turn..");
           printf(" 1.Roll dice:");
           scanf("%d",&option);
           if(option==1){
               dice=rand()%6+1;
               printf(" %d",dice);
               if(dice==6){
                   turn=1;
               }
               else{
                   player1=player1+dice;
                   printf(" Player1 score:%d",player1);
                   if(player1>=100){
                       printf(" Player1 wins....");
                       printf(" 1.restart");
                       printf(" 2.exit");
                       printf(" Enter your option:");
                       scanf("%d",&option);
                       if(option==1){
                           player1=0;
                           player2=0;
                           turn=0;
                       }
                       else
                           break;
                   }
               }
           }
           else{
               printf(" Invalid option...");
           }
       }
       else{
           printf(" Player2 turn..");
           printf(" 1.Roll dice:");
           scanf("%d",&option);
           if(option==1){
               dice=rand()%6+1;
               printf(" %d",dice);
               if(dice==6){
                   turn=0;
               }
               else{
                   player2=player2+dice;
                   printf(" Player2 score:%d",player2);
                   if(player2>=100){
                       printf(" Player2 won the game....");
                       printf(" 1.restart");
                       printf(" 2.exit");
                       printf(" Enter your option:");
                       scanf("%d",&option);
                       if(option==1){
                           player1=0;
                           player2=0;
                           turn=0;
                       }
                       else
                           break;
                   }
               }
           }
           else{
               printf(" Invalid option...");
           }
       }
   }
   return 0;
}

OUTPUT: The output is too large to take screenshot.

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