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

  Program to display aggregate information for state

For each state, display aggregate information for that state, including: the total number of counties in the state, the total number of tax returns.

  Application to feature a gui

A program written in Dr. Racket Scheme that makes use of lists, higher order procedures (e.g. map, filter, reduce) and/or recursion. If all of those could be used it would be best

  Designing menu for administrator to simulate transmissions

Design a menu which permits administrator to simulate transmissions of information by manually typing in login or logoff data.

  How many database requests can you identify

Write the complete transaction(s).

  Necessary vhdl code

Assignment 1:Project Assignment: You are required to design an energy meter based on CPLD (Complex Programmable Logic Device) that will smartly disconnect the supply when sufficient amount of energy units are consumed. The device needs to be programm..

  Write program-compute average using floating-point numbers

Write a program that will accept as input between 2 and 25 numbers and then calculate the average of the numbers. Make sure you use floating-point numbers in case the average is not a whole number.

  Write a c# application that generates a 3-digit random no

Every 10th number you should display a String consisting of a any phrase of your choice concatenated with the current random number.

  View and change sas system options

View and change SAS system options. Justification date orientation, ect

  Develop application for company having breakdown of payroll

Develop the logic for application for company which wishes report containing breakdown of payroll by department. Input comprises each employee's name, department number.

  Identify the errors

Identify the errors in the following program segment. Determine the output displayed when the button is clicked:

  Create the program uses two arrays to hold employee names

Create the program which uses two arrays: one to hold employee names and one to hold employee salaries (standard US currency, two decimal points). The program must prompt user to enter employee names.

  Write a program to enter the number of apartment units

Write a program that prompts the user to enter the number of apartment units, the rent to occupy all the units, the increase in rent that result in a vacant unit.

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