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

See image for instructions. My current code is listed below in the link and in t

ID: 646042 • Letter: S

Question

See image for instructions. My current code is listed below in the link and in text underneath that. I'm currently having problems trying to print the Dice Stats Histogram - I don't know how to print the stars for each number. We haven't reviewed arrays at all or creating functions much in class yet, so I am trying to stay away from them. If need be, go ahead and add arrays.

Thank you very much :)

https://ideone.com/eOSwqj#

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

void introduction_Message (void);


int main(void)
{
   // Data Storage
   int i = 0; // Loop counter iterates numRolls times
   int numRolls = 0; // User defined number of rolls
   int numTwos = 0;
   int numThrees = 0;
   int numFours = 0;
   int numFives = 0;
   int numSixes = 0;
   int numSevens = 0;   
   int numEights = 0;
   int numNines = 0;
   int numTens = 0;
   int numElevens = 0;
   int numTwelves = 0;
   int die1 = 0; // Dice values
   int die2 = 0; // Dice values
   int rollTotal = 0; // Sum of dice values
  
  
   introduction_Message();
  

   printf (" Enter number of Rolls: ");
   scanf("%d", &numRolls);
  
  
   while (numRolls >= 1) {
      
   srand(time(0));
      
   if (numRolls >= 1) {
       // Roll dice numRoll times
       for (i = 0; i < numRolls; ++i) {
           die1 = rand() % 6 + 1;
           die2 = rand() % 6 + 1;
           rollTotal = die1 + die2;
          
           // Count number of sixs and sevens
           if (rollTotal == 2) {
               numTwos = numTwos + 1;
           }
           else if (rollTotal == 3) {
               numThrees = numThrees + 1;
           }
           else if (rollTotal == 4) {
               numFours = numFours + 1;
           }
           else if (rollTotal == 5) {
               numFives = numFives + 1;
           }
           else if (rollTotal == 6){
               numSixes = numSixes + 1;
           }
           else if (rollTotal == 7) {
               numSevens = numSevens + 1;
           }
           else if (rollTotal == 8) {
               numEights = numEights + 1;
           }
           else if (rollTotal == 9) {
               numNines = numNines + 1;
           }
           else if (rollTotal == 10) {
               numTens = numTens + 1;
           }  
           else if (rollTotal == 11) {
               numElevens = numElevens + 1;
           }      
           else if (rollTotal == 12) {
               numTwelves = numTwelves + 1;
           }
           else
           {
               printf ("Error in roll calculations");
           }          
          
           printf(" Roll %d is %d (%d+%d)",i+1,rollTotal,die1,die2);
       }
  
      
       // Print statistics on dice rolls
       printf(" Dice roll statistics: ");
       printf("2s: %d ",numTwos);
       printf("3s: %d ",numThrees);
       printf("4s: %d ",numFours);
       printf("5s: %d ",numFives);
       printf("6s: %d ",numSixes);
       printf("7s: %d ",numSevens);
       printf("8s: %d ",numEights);
       printf("9s: %d ",numNines);
       printf("10s: %d ",numTens);
       printf("11s: %d ",numElevens);
       printf("12s: %d ",numTwelves);
  
       // Prints dice roll histogram
       printf (" -- Dice Roll Histogram -- ");

       printf (" 2: ");
       printf (" 3: ");
       printf (" 4: ");
       printf (" 5: ");
       printf (" 6: ");
       printf (" 7: ");
       printf (" 8: ");
       printf (" 9: ");
       printf (" 10: ");
       printf (" 11: ");
       printf (" 12: ");

      
  
       // Get new number of rolls
       printf (" Enter number of Rolls: ");
       scanf("%d", &numRolls);
      
   }
   }
   // Error message for negative input
   printf (" Negative number inputted. Try again!");
  
  
   return 0;
}

// ***********************************************
// Name : introduction_Message
// Data Passed in: None
// Data Returned: None
// Description: Prints welcome message to screen.
// ***********************************************

void introduction_Message (void)
{
   printf(" Greetings, user! This program will calculate the number of times the sum of a randomly rolled dice equals each possible value from 2-12. The program will keep a running total of your dice totals, so you may enter multiple sets of rolls. To use this program, simply input the number of rolls you'd like to see statistics for! ");

}

Explanation / Answer

#include

#include

#include

void introduction_Message
(void);



int main(void)

{

// Data Storage

int i = 0; // Loop
counter iterates numRolls times

int numRolls = 0; // User defined number of
rolls

int numTwos = 0;

int numThrees = 0;

int numFours = 0;

int numFives = 0;

int numSixes = 0;

int numSevens = 0;

int numEights = 0;

int numNines = 0;

int numTens = 0;

int numElevens = 0;

int numTwelves = 0;

int die1 = 0; // Dice values

int die2 = 0; // Dice values

int rollTotal = 0; // Sum of dice values





introduction_Message();



printf
(" Enter number of Rolls: ");

scanf("%d", &numRolls);





while (numRolls >= 1) {



srand(time(0));



if (numRolls >= 1) {

// Roll dice numRoll times

for (i = 0; i < numRolls; ++i) {

die1 = rand() % 6 + 1;

die2 = rand() % 6 + 1;

rollTotal = die1 +
die2;



// Count number of
sixs and sevens

if (rollTotal == 2) {


numTwos = numTwos + 1;

}

else if (rollTotal ==
3) {


numThrees = numThrees + 1;

}

else if (rollTotal ==
4) {


numFours = numFours + 1;

}

else if (rollTotal ==
5) {


numFives = numFives + 1;

}

else if (rollTotal ==
6){


numSixes = numSixes + 1;

}

else if (rollTotal ==
7) {


numSevens = numSevens + 1;

}

else if (rollTotal ==
8) {


numEights = numEights + 1;

}

else if (rollTotal ==
9) {


numNines = numNines + 1;

}

else if (rollTotal ==
10) {


numTens = numTens + 1;

}

else if (rollTotal ==
11) {


numElevens = numElevens + 1;

}


else if (rollTotal ==
12) {


numTwelves = numTwelves + 1;

}

else

{


printf ("Error in roll calculations");

}




printf(" Roll %d
is %d (%d+%d)",i+1,rollTotal,die1,die2);

}





// Print statistics on dice rolls

printf(" Dice roll statistics:
");

printf("2s: %d ",numTwos);

printf("3s: %d ",numThrees);

printf("4s: %d ",numFours);

printf("5s: %d ",numFives);

printf("6s: %d ",numSixes);

printf("7s: %d ",numSevens);

printf("8s: %d ",numEights);

printf("9s: %d ",numNines);

printf("10s: %d ",numTens);

printf("11s: %d ",numElevens);

printf("12s: %d ",numTwelves);



// Prints dice roll histogram

printf (" -- Dice Roll Histogram --
");


printf (" 2: ");

printf (" 3:
");

printf (" 4:
");

printf (" 5:
");

printf (" 6:
");

printf (" 7:
");

printf (" 8:
");

printf (" 9:
");

printf (" 10:
");

printf (" 11:
");

printf (" 12:
");






// Get new number of rolls

printf (" Enter number of Rolls:
");

scanf("%d", &numRolls);



}

}

// Error message for negative input

printf (" Negative number inputted. Try again!");





return 0;

}

//
***********************************************

// Name : introduction_Message

// Data Passed in: None

// Data Returned: None

// Description: Prints welcome message to screen.

// ***********************************************

void introduction_Message (void)

{

printf(" Greetings, user! This program will calculate
the number of times the sum of a randomly rolled dice equals each possible
value from 2-12. The program will keep a running total of your dice totals, so
you may enter multiple sets of rolls. To use this program, simply input the
number of rolls you'd like to see statistics for! ");

}