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

  Necessary documentation for a mock meeting for the project

Create the necessary documentation for a mock meeting for the project. Create a sample progress report for the key stakeholders in the project.

  Write application layer protocols to permit through firewall

As part of your own planning process, write the application layer protocols which you would permit through the firewall, those you would block and your reasons for doing so.

  Deploy several visual basic.net applications

Your supervisor has asked you to develop a plan to deploy several Visual Basic.NET applications to users in your company.

  Design and run a program that takes a numerical score

Design and run a program that takes a numerical score and outputs a letter grade. Precise numeral scores and letter grades are listed show.

  Business rules form the basis of the database design.

A member receives many invitations, and each invitation is sent to many members.

  Write program to calculate miles per gallon for automobile

Write down the program which calculates miles per gallon for automobile. The program must ask for beginning milage reading on odometer at first.

  Write pseudocode for the function of nonplayercharacter

Identify two additional classes needed for a more detailed class model. Their names should be descriptive enough to indicate their overall responsibilities.

  Prepare a assignment in sql

Prepare a assignment in SQL. To create two table names (not in use employee ,product ,order )- Separate queries of all function,screen shots and queries.

  Create a r-wr property named validlastname stores string

Create a read-write property named ValidLastName that stores a String value in the hidden variable mstrLastName.

  Write application to simulate coin tossing

Write an application that simulates coin tossing. Let the program toss the coin each time the user presses the "Toss" button. Count the number of times each side of the coin appears.

  Create a script that requires o accept terms and conditions

create a script that requires yours visitors to accept your terms and conditions before proceeding, by selecting a check box.

  Design program that stores information of products

You are asked to design a program that stores information of given products. Your program must be menu driven. The program menu must include the following options: Add product information (Ask user to input product id, name and price)

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