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

Above information it says to write a program that asks the user to guess the nex

ID: 3914258 • Letter: A

Question

Above information it says to write a program that asks the user to guess the next roll of a six sided die. Each guess costs $ 1. If they guess correctly, they get $ 100. The player will start out with a $10 bank. Each time he guesses incorrectly you will subtract $1.00 from their bank. Each time they guess correct, you add $10.00 to their bank. Print the total winnings or loss at the end of the game. You can simulate the toss of the dice using the RandomRange function (don’t forget to randomize). The program should look like this: Your bank is $10.00 Please enter your guess for the next roll. It only costs $1.00 to play, if you are correct I will pay you $10.00:
6 sorry, the dice rolled a 5. continue? Y Your bank is $9.00 Please enter your guess for the next roll It only costs $1.00 to play, if you are correct I will pay you $10.00
4 winner! the dice rolled at 4. Continue? N Thanks for playing your bank is $19.00 Come back real soon
Format this in the assembly language form from the Irvine library Come back real soon RandomRange PROC Generates an unsigned pseudo-random 32-bit integer in the range of 0 through (n-1) Call args: EAX-, the range Return arE: EAX -randon (e to n-1) Example: Get a randos number from 1 to 100 data rantun DWORD code eax,100 ;get randos e to ” call Randomkangei imake range 1 to 1ee nov ranNus,eax isave randon number To generate a 32-bit random number, use the Random32 Procedure: Random32 PROC Generates an unsigned pseudo-random 32-bit integer in the range of 0 through FFFFFFFFh. Call argsi None Return arg: EAX random ( to FFFFFFFFh) Example: .data ranNum DHORD code call Random32 mov ranNum, eax save Randomize PROC Re-seeds the random number generator with the current time in hundredths of seconds. Call args: None Return arg: None Example: call Randonize ire-seed generator The output of your game should look something like this but please note it is difficult to show you each iteration. uld you tike to contnue? (yn) you are correct T wili pay you 530.0 rry you Jose. The dice rolled our bank is now 9 ld you 1the to cont nue? (y/n)

Explanation / Answer

Here you have to write the menu driven program so that the user get the choice of enter to play again and again

#include <stdio.h>

#include <stdlib.h>

#include<string.h>

#include<ctype.h>

#include<time.h>

void computerGenerator();

void winningNumbers();

void inputstring( char *inputptr );

void printarray(int * arrpt);

void playChoice();

void guess();

void ending();

char inputarray[512];

char *inputptr = inputarray;

int main()

{

   char start;

   srand(time(NULL));

   int counter=0;

   char choice;

   int numPlay=0;

   int lotto[6][5];

   int r, c;

  

   printf("Welcome to the dice guess game ");

    

   printf(" would you like to continue?(y/n) ", &start);

   scanf("%c", &start);

   fflush(stdin);

     if (start == 'y')     // begin if "yes"

     {

         system("cls");

         printf("How many games would you like to play? ");

         scanf("%d", &numPlay);

         fflush(stdin);

         system("cls");   // clear screen

  

  

         scanf("%c", &choice);

         fflush(stdin);

      if (choice == 'q')     // begin if "yes"

      {

          system("cls");

              printf("Your quick pick numbers are: ");

              printf("---- ----- ---- ------- ---- ");

          for( counter=numPlay; counter > 0; counter--)

          {

               computerGenerator();

          }//end for

      }    //end if

     else

     {

           system("cls");

           printf("Please enter your numbers: ");

  for(r=0; r<numPlay; r++)

  {

         for(c=0; c < 1; c++)

        {

           scanf("%d", &lotto[c][r]);

        }

  } //end for r

  system("cls");

  printf("Here are your %d hand-picked numbers: ", numPlay);

  printf("---- --- ---- - ----------- -------- ");

    for(r=0; r<numPlay; r++)

    {

            for(c=0; c < 1; c++)

            {

                printf("%2d ", lotto[c][r]);

            }

       printf(" ");

     } //end for c

   }// end for

      winningNumbers();

   } //end if

       else                // begin if "no"

       {

          system("cls");   // clear screen

          printf(" ");

          printf("      Aww...you don't want to try my program? ");    // ending

          printf(" Who needs you anyway, huh? Go buy a real ticket. ");

          printf(" Another project brought to you by Me ");

       }   // end else

   printf(" ");

   system("PAUSE");

   return 0;

}   //end main

void inputstring( char *inputptr )

{

    while ( ( *inputptr++ = getchar() ) != ' ' )

       {

         //printf("%c", (*inputptr));

        }

        //        printf(" ");

        *( --inputptr ) = '';

}

void computerGenerator()

{

   int array[6]={0};

   int arrlen;

   arrlen = sizeof(array)/sizeof(int);

   for(int x=0; x < arrlen; x++ )

   {

       array[x] = (int) rand()%53+1;

       for(int y=0; y<x; y++)

       {

          if (array[y] == array[x])

          {

             array[x] = (int) rand()%53+1;

             y=0;

          } //if()

       }   //for (y)

    } //for (x)

    // sort array using swap and bubbles

    for(int y=0; y < arrlen-1; y++ )

    {

       for(int x=0; x < arrlen-1; x++ )

       {

          if (array[x] > array[x+1])

          {

             int temp;

             temp = array[x];

             array[x] = array [x+1];

             array [x+1] =temp;

          } //

       }   //

    } //

    printarray(array);

}   // end generator

void winningNumbers()

{

   int array[6]={0};

   int arrlen;

   arrlen = sizeof(array)/sizeof(int);

   for(int x=0; x < arrlen; x++ )

   {

       array[x] = (int) rand()%53+1;

       for(int y=0; y<x; y++)

       {

          if (array[y] == array[x])

          {

             array[x] = (int) rand()%53+1;

             y=0;

          } //if()

       }   //for (y)

    } //for (x)

    // sort array using swap and bubbles

    for(int y=0; y < arrlen-1; y++ )

    {

       for(int x=0; x < arrlen-1; x++ )

       {

          if (array[x] > array[x+1])

          {

             int temp;

             temp = array[x];

             array[x] = array [x+1];

             array [x+1] =temp;

          } //

       }   //

    } //

    printf(" The winning lotto numbers are: ");

    printf("--- ------- ----- ------- ---- ");

    printarray(array);

}   // end generator

void printarray(int*arrpt)

{

   for (int x=0; x<6; x++)

   {

       printf("%2d ", arrpt[x]);

   }

   printf(" ");

}      // end printarray

void guess()

{

    int play[6]={0};

    printf("Enter the six numbers you want to play ");

    printf("Type them in separating by a space ");

    inputstring( inputptr );

    system("CLS");

}

void ending()

{

     int iochar;

     printf(" Your hand-picked numbers are: ");

     printf( inputarray );

     printf(" ");

}