Question

In: Computer Science

Please solve me this question and send me the video clip how to do it This...

Please solve me this question and send me the video clip how to do it

This problem contains loops, sorting arrays, random generation, and variable matching.

Include an analysis (data requirements) and algorithm in your reply.

Write a “lottery engine” program to simulate drawing lottery numbers. You will draw 7 numbers, randomly selected from 1 to 16.

a) Allow the user to enter their own selection of numbers first,

Example numbers: 2 3 7 9 10 11 15

b) then run your “lottery engine” to select the “winning numbers”. Numbers are drawn randomly.

Use the clock as the seed value for your random function (Hint: use “srand(clock());” ).

c) Be sure to remove duplicate entries.

d) Print out the draw result as it was generated (unsorted), then sort the array and print out the sorted numbers.

Example output:

Draw unsorted: 2 12 16 14 7 13 1

Draw sorted: 1 2 7 12 13 14 16

e) Then print out the matching numbers selected by the user:

f) Also print the sorted user selection and draw results and matching numbers to a TXT file called “Results.txt”.

Example output

Draw sorted: 1 2 7 12 13 14 16

User’s sorted: 2 3 7 9 10 11 15

Matching numbers: 2 – 7

Solutions

Expert Solution

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

// generate_random() function to generate array of random no.
void generate_random(int *a, int n)
{
  {
    int main();

    int i, n, j;
    time_t t;

    n = 7;

    /* Intializes random number generator */
    srand((unsigned) time(&t));

    /* Print 5 random numbers from 0 to 50 */
    for (i = 0; i < n; i++) {

      printf("%d\n", rand() % 16);
    }
  }
  int j, temp, i;
  // Passed starting address and size to generate array of random numbers
  generate_random(a, n);
  // Displaying the random array
  printf("\n The random array: ");
  for (i = 0; i < n; i++)
    printf(" %d ", a);

  for (i = 1; i < n; i++) {
    for (j = 0; j < n - i; j++) {
      /* To sort in ascending order, change '<' to '>' to implement descending order sorting */
      if (a[j + 1] < a[j]) {
        temp = a[j];
        a[j] = a[j + 1];
        a[j + 1] = temp;
      }
    }
  }

  // Displaying the sorted array.
  printf("\n The sorted array: ");
  for (i = 0; i < n; i++)
    printf(" %d ", a);
  printf("\n \n");
}

Related Solutions

Can someone please show me how to do the work on this please. Question The transactions...
Can someone please show me how to do the work on this please. Question The transactions of the Fury Delivery Service are recorded in the general journal below. Instructions: 1. Post the journal entries to the attached general ledger “T” accounts. 2. Prepare a trial balance on the form provided after the “T” accounts. General Journal Date Account Titles and Explanation Debit Credit 2017 Sept. 1 Cash Common Stock (Stockholders invested cash in business) 25,000 25,000 4 Equipment Cash Notes...
Please give me step by step answer how to solve this question: Consider the following example....
Please give me step by step answer how to solve this question: Consider the following example. In a study reported in the California Journal of Nursing, nurses were asked to report their degree of job-related stress. They were asked 20 questions about their work and they responded on a 1-5 scale as the amount of stress they felt (5 being the most). These responses were added up in order to come up with a numeric measure of job stress. Below...
Could you please explain step by step how to resolve this problem? Please don't send me...
Could you please explain step by step how to resolve this problem? Please don't send me the one that is already posted, I want a new explanation. Thank you. At the end of the month, the M&M Company had completed Job Red and Job Yellow. The individual job cost sheets reveal the following information: Job Direct Materials Direct Labor Machine Hours Job Red $6,720 $2,016 24 Job Yellow 12,966 4,104 76 ​ Job Red produced 144 units, and Job Yellow...
can you please solve this for me. please write a paragraph for each question and explain...
can you please solve this for me. please write a paragraph for each question and explain your reasoning. 1) assume that you are a full-time worker earning $10/hour, $80/day, $400/week, $20000/year. would you be willing to quit your jobs or keep working if the tax rate was 10%? 20%? 30%? 40%? what do you think is the best tax rate? what do you think is the best tax rate? 2)the state of California has decided to increase funding for public...
After viewing the video clip (Remember the Titans) in your Ch. 7 powerpoint, please provide an...
After viewing the video clip (Remember the Titans) in your Ch. 7 powerpoint, please provide an example of each stage of the group process: 1. Forming: 2. Storming: 3. Norming: 4. Performing: 5. Adjourning: Then, please provide a personal example of a group experience you have had, and describe a phase of the group process that was memorable. Please respond to a peer's experience thoughtfully.
Please show all your work in Excel, please send me the spreadsheet / workbook. What is...
Please show all your work in Excel, please send me the spreadsheet / workbook. What is the market value of the following bond? Coupon 8% Maturity date 2038 Interest paid semiannually Par Value $1000 Market interest rate 10% What is the market value of the following bond? Coupon 9% Maturity date 2028 Interest paid semiannually Par Value $1000 Market interest rate 8% What is the yield to maturity of the following bond? Coupon 9% Maturity date   2027 Interest paid semiannually...
Please tell me how to solve the following questions a) to c) using a graph. In...
Please tell me how to solve the following questions a) to c) using a graph. In particular, please elaborate on c). Cellwave is a cellular phone company. Answer the following questions relating to its pricing policies: a) When Cellwave started, it sold to a group of homogeneous retail customers. Each person’s monthly demand for cell phone minutes was given by P = $2 - 0.02Q , where P = the price per minute and Q = the quantity of minutes...
Can you solve and send me the original code which I can copy and paste plz....
Can you solve and send me the original code which I can copy and paste plz. Thank you. Kahn's Algorithm Implement Kahn's Algorithm for giving a topological ordering of a graph as discussed in class. The input graph will be in adjacency list format. 1. Count the in-degree (number of edges ending at) each vertex. 2. Create a queue of nodes with in-degree 0. 3. While the queue is not empty: a. Add the first element in the queue to...
hi, can you draw me a cloud using turtle from python. please send me the codes
hi, can you draw me a cloud using turtle from python. please send me the codes
PLEASE SHOW ME HOW TO SOLVE THIS ALGEBRAICALLY. SPECIFICALLY SHOW HOW TO GET THE COUPON PAYMENT...
PLEASE SHOW ME HOW TO SOLVE THIS ALGEBRAICALLY. SPECIFICALLY SHOW HOW TO GET THE COUPON PAYMENT PLEASE. Smiley Industrial Goods has bonds on the market making annual payments, with 13 years to maturity, and selling for $1,095. At this price, the bonds yield 6.4 percent. What must the coupon rate be on these bonds?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT