Write a program that simulates the lottery

Assignment Help Programming Languages
Reference no: EM131119390

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.

Reference no: EM131119390

Questions Cloud

Interest and a qualitative methodology : In this assignment, you will apply the chosen topics of your interest and a qualitative methodology (case study, phenomenology, grounded theory, ethnography, or narrative approaches). For this, you need to use a list of open-ended interview questi..
Final technical paper types appeals : Talk about which one of the three final technical paper types appeals to you and explain why. You can get some information from the attach file.
Explain the impact those marketing recommendations : The first of the “365” stores is set to open in 2016 in the Silver Lake neighborhood of Los Angeles, named America’s No. 1 hippest hipster neighborhood by Forbes. The area is known for its large arts community, having risen to fame as the location of..
In which month should the batches be produced : A manufacturing firm has a contract to supply lathe chucks as per the following schedule. In which month should the batches be produced and of what size, so that the total of setup and inventory carrying cost arc minimized
Write a program that simulates the lottery : 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!
Identify the psychological element of the protagonist : Elsewhere is undoubtedly a character-driven piece so spend some time dissecting the characters a bit (round or flat, dynamic or static). Who are the protagonist and antagonist and what are their motivations? Explore Dr. Case's role in the storylin..
There are a variety of methods for revenue recognition : There are a variety of methods for revenue recognition. Define and describe each of the following methods of revenue recognition, and indicate whether each is in accordance with generally accepted accounting principles.
Installing an enterprise resource planning system : Do you think that installing an Enterprise Resource Planning system would be worth it, even at a cost of, say $100 million (for a fairly large firm)? How does this differ if you were managing a small-to-medium-size firm and the installation cost was,..
A business plan for durango manufacturing company : 1. As the consultant, create an argument that you will present to the CEO that suggests accounting and financial management knowledge and skills will be essential to the company's success and stability over the next five (5) years. Provide support ..

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a function that carries out the desired action

Create your own assignment to get more practice with arrays. Listed below are twenty seven functions you can write that deal with arrays. Listed next to each function is a number of points each is worth in parenthesis. Create a function that carri..

  Develop a functional web-based application for a calculator

Develop a functional web-based application for a calculator. It does not need to be live; you can provide JavaScript, CSS, and HTML files. The calculator should successfully complete addition, subtraction, multiplication, and division operations.

  Determines which patients have a high systolic pressure

Application determines which patients have a high systolic pressure and provides a process to contact them for follow up consultation.

  Step by step procedure to solve to create record note book

Create Record note book; The Record note book should be in the follwoing order. Procedure: Write down step by step procedure to solve problem.

  Write program which reads three integer from input dialogs

Write down the program which reads three integer. Integers are entered from input dialogs and stored in variable num1, num2, and num3, respectively.

  Program to compute person earns in a month

Write a program that calculates how much a person earns in a month if the salary is one penny the first day, two pennies the second day, four pennies the third day.

  Electro-magnetic force in newtons

The topic of this assignment was chosen so that you won't allow mathematical equations and scientific notation to intimidate you. No knowledge is required to complete the assignment beyond knowing how to perform mathematical operations within a fo..

  Write and implement generic set class with attributes

Write and implement the generic Set class with attributes you find essential and with the following methods. Set class has nonduplicate elements.

  Program to print total balances forward and total withdrawal

At the end of report, print total balances forward, total deposits, total interest earned, total withdrawals and total final account balances.

  Matlab that will use the flipping of two-sided coins to sim

Write a program in matlab that will use the flipping of two-sided coins to simulate any event that has a probability of success(Ps) that ranges between 0 and 1. The simulation will most likely be approximate. It must be accurate to at least 0.01

  What is a program in technical perception

What is a program in technical perception? Why it is required?

  Create an event to activate the method

In this exercise, you will build a simple flight simulator using alice 2.2. You will start with a water world, add a seaplane to the world, build events to allow the user to control the plane, and then add other objects to the world to make it loo..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd