For this problem you will simulate the lottery to put your


1. There comes a time in all our lives where we decide that the daily grind just isn't worth it and we set our sights on new opportunities. Some who have this revelation late at night may invest in a truck-driving certificate or a correspondence course involving vague promises about working in technology, and that your family will be proud of you. Many of us will resort to the lottery. (You can't win if you don't play - of course you probably can't win if you do play, but the advertisements don't mention that). For this problem, you will simulate the lottery to put your programming knowledge for use in something practical.Write a program that simulates the lottery to help in becoming obscenely wealthy with no work whatsoever!

The interface is shown below:

1494_Initial interface.jpg

Initial interface

The size of pool cell provides a user input value to determine how many numbers are in the lottery. In the above example, the lottery contains numbers 1-56. Cells under the ‘User' heading are the user input guesses - in this case the user is guessing 6 numbers out of 56 (like the Megamillions game...).

Your program will create a dynamic array the size of the pool (an array with 56 elements in the example)). Each member of the array will contain a randomly chosen number in the range of the pool (1-56 in the example). It is important to note that a number can only be in this array once (so array elements 1-56 will contain all the numbers from 1-56, but in a random order). For example ar(1) = 47, ar(2) = 12, ar(3) = 32 .....ar(56) = 25.

A second dynamic array will be created and used to store the user guesses. The user can have anywhere from 1 to the pool size. While the figure shows places for approximately 15 guesses, your program must be structured so that the number of user guesses can be as large as the entire pool (which would make the lottery much easier). The program must determine how many guesses the user has input, use this value to redimension a dynamic array to the appropriate size, and then input the user guesses into the array.

The number of lottery values output will be the same as the number of user guesses. For the lottery numbers, they will be the first elements of the array (elements 1-6 in the example). Your program will then compare the values in the user guesses to the values in the lottery column and output the number of values in both arrays (1 in the example).

1858_Lottery Generator.jpg

2. All of you should know how to calculate a derivative analytically. In CME 318 you will learn how to calculate a derivative numerically, and this problem will have you program a very basic numerical differentiation.

572_Derivative Function.jpg

To calculate a numerical derivative, first a value of x is chosen (the location where the derivative will be calculated). A secant line is drawn that intersects the function at two places f(x + h/2) and f(x - h/2), and these two function bracket the x value. The derivative is calculated as the slope of this line.

dy/dx = {f(x + h/2) - f(x - h/2)} / 2

As shown in the figure, the value calculated from this method will be different than the actual derivative. As the distance h decreases in magnitude, the value of the derivative will become closer to the actual value.

Write a program that calculates the numerical derivative of the following function:

f(x)=3/(1+2e(-0.5x))

For a given value of x, begin with a value of h = 1 and calculate the derivative. Divide h by two and recalculate the derivative. The tolerance is the difference between these values. Keep repeating the procedure (dividing h by 2 every time) until the tolerance is less than a user entered value. Output the number of iterations, the value of the derivative and the tolerance.

Constraints of your program are:

Have both the value x (where the derivative will be calculated) and the tolerance be user input values from the spreadsheet. (As shown in the figure.)

Calculate the tolerance beginning with the second derivative calculation.

Use a Function to calculate the values of the function (f(x)). This will allow the user to easily change the function.

Test your program with a function you can take the derivative analytically (through calculus).

Submit a validation of your program.

Below is a sample interface. The user enters values for x and tolerance, and then shows the calculated derivative and tolerance for each iteration.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: For this problem you will simulate the lottery to put your
Reference No:- TGS01497342

Expected delivery within 24 Hours