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

C programing check this link to understand the game . www.yahtzeeonline.org. the

ID: 3595894 • Letter: C

Question

C programing




check this link to understand the game .
www.yahtzeeonline.org.
the game is text based however.

I. Learner Objectives At the conclusion of this programming assignment, participants should be able to: Apply repetition structures within algorithms Construct while (), for (), or do-while () loops in C Apply pointers, output parameters, and/or arrays in C Compose C programs consisting of sequential, conditional, and iterative statements Eliminate redundancy within a program by applying loops and functions Create structure charts for a given problem Determine an appropriate functional decomposition or top-down design from a structure chart Generate random numbers for use within a C program Il. Prerequisites: Before starting this programming assignment, participants should be able to: eAnalyze a basic set of requirements and apply top-down design principles for a problem e Customize and define C functions Apply the 3 file format: 1 header file and 2 source files e Open and close files e Read, write to, and update files eApply standard library functions: fopen (), fclose (0, fscanf (0, and fprintf 0 Compose decision statements ('if conditional statements) Create and utilize compound conditions Summarize topics from Hanly & Koffman Chapter 4 & 5 including: e What are counting, conditional, sentinel-controlled, flag-controlled, and end file-controlled loops What are while (), do-while (), and for ( ) loops What is a selection or conditional statement What is a compound condition What is a Boolean expression What is a flowchart e e IlIl. Overview & Requirements: invanted bu Milton Bradley and Edwin S. Lowe in 1956. The chall

Explanation / Answer

code for the above program:

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void score();
int main()
{   void gamerules();
    void game();
   int choice;
   int i=1;

   do{
   printf("***MENU*** 1.Print the rules 2.Start a new Game 3.Exit Enter one of the input value (1,2,3) :");
   scanf("%d",&choice);
   system("cls");
   switch(choice)
   {
       case 1: gamerules();break;
       case 2: game();break;
       case 3: printf("Goodbye from the game ");exit(0);
      
   }
   i=choice;
    }while(i!=1||i!=2);
}
void gamerules()
{
   //you can write the rules on your own
}

void game()
{
   int dice[5];int count=0,i;int move;int ch;int verify[13]={0};int rrl;int ch1;
   printf("press any key (0-9) to roll the dice ");
   scanf("%d",&move);
   for(i=0;i<5;i++)
   dice[i]=rand()% 6 + 1 ;
   printf("face value of each dice 1-->%d 2-->%d 3-->%d 4-->%d 5-->%d ",dice[0],dice[1],dice[2],dice[3],dice[4]);
    count++;
    printf("select one of the combination ");
   printf("1.Sum of 1's 2.Sum of 2's 3.Sum of 3's 4.Sum of 4's 5.Sum of 5's 6.Sum of 6's 7.Three of a kind 8.Four of a kind 9.Fullhouse 10.Small straight 1.Large straight 12.Yahtzee 13.Chance ");
    scanf("%d",&ch1);
   do
   {
      
    printf("if you want to use the roll for combination-- press 0/1 ? ");
    scanf("%d",&ch);
    if(ch==1)
    select_combination(ch1,dice,verify);
    else if(ch==0)
    {
       printf("which dice u want to re-roll (1-5)");
       count++;
       for(i=0;i<5;i++)
       {
           printf("want to re-roll dice %d press 0/1 ?",i+1);
           scanf("%d",&rrl);
           if(rrl==1)
           dice[i]=rand()%6+1;
          
       }
       printf("face value of eacj dice 1-->%d 2-->%d 3-->%d 4-->%d 5-->%d ",dice[0],dice[1],dice[2],dice[3],dice[4]);
   }
    }while(count!=3&&ch==0);
  
}

void select_combination(int ch,int* dice,int* verify)
{
    if(verify[ch-1]==0){
    verify[ch-1]=1;score(dice,ch);
    }
    else
    {
       printf("combination used ");
    score(0);
  
    }
}

void score()
{
   //as no details is told about scoring part,,,,it is left to user
}