Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

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.

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91876954

Have any Question?


Related Questions in Programming Language

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

Extend the adworks applicationi add dialogs to allow the

Extend the AdWorks application I. Add Dialogs to allow the user to Add, Edit, Read and Delete a Customer and refresh the view accordingly. 1. The user should be able to select a specific customer from the DataGrid and cl ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Question 1 what is a computer program what is structured

Question: 1. What is a Computer program? What is structured programming? 2. What is modular programming? Why we use it? 3. Please evaluate Sin (x) by infinite series. Then write an algorithm to implement it with up to th ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question 1 what is hadoop explaining hadoop 2 what is

Question: 1. What is Hadoop (Explaining Hadoop) ? 2. What is HDFS? 3. What is YARN (Yet Another Resource Negotiator)? The response must be typed, single spaced, must be in times new roman font (size 12) and must follow t ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As