Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Jurses TOLICUCULU/project2.pdf Overview: You have decided to buy lotteries to try your luck. You want to write a C++ program that will calculate the odds

image text in transcribed
image text in transcribed
image text in transcribed
Jurses TOLICUCULU/project2.pdf Overview: You have decided to buy lotteries to try your luck. You want to write a C++ program that will calculate the odds of winning a lottery. You will buy both "lotto" and "powerball" lotteries. In the "lotto" lottery, you choose six (6) unique and different numbers from 1 to 50. You win the jackpot if all 6 of your numbers match all 6 of their numbers - in any order. In the "powerball" lottery, you choose 5 unique and different numbers from 1 to 50, then for the sixth ball, you will choose any number from 1 to 50 (it can be different than the first 5, or it can match one of them - it doesn't matter). To make your program simple, you will consider a lottery where you will pick only three (3) numbers. The following examples illustrates how you can calculate the odds if the maximum number you can pick is 20. Lotto Calculate the 3 probability factors: P1 = 3/20 = 0.15 (Probability that one of the 3 picks will match one number) P2 = 2/19 = 0.105263 (Probability that one of the 2 remaining picks will match one number) P3 = 1/18 = 0.055556 (Probability that the remaining 1 pick will match one number) Multiply all the factors to calculate the probability that you'll win: P = P. * P2 * P = 0.000877 Divide 1 by the answer to see the odds against you! You have a 1 in 1140 chance of winning since 1 / 0.000877 = 1140. Powerball Calculate the 3 probability factors: P1 = 3/20 = 0.15 (Probability that one of the 3 (initial) picks will match one number) P2 = 2/19 = 0.105263 (Probability that one of the 2 remaining picks will match one number) Calculate the 3rd (powerball) factor. P = 1/20 - 0.05 (Probability that your powerball will match one number) Multiply all the factors to calculate the probability that you'll win: P-P. * P2 * P = 0.0007895 (this is the probability you'll win) Divide 1 by the answer to see the odds against you! You have a 1 in 1266 chance of winning since 1/ 0.0007895 = 1266. In the program, you will need to ask the user to enter the maximum number you can pick (e.g., 20 in the previous example). Make sure your input/output is exactly the same as shown in the Sample Executions. Instructions: This will be an individual programming project. Use meaningful variable names, helpful comments, and a consistent coding style. Your program file should have the appropriate comment block at the top: // Name: Your Name // Date: Day Month, Year // Program Description: brief description of the program Deliverables: You will need to submit the following in Blackboard by 11:59 PM on February 24th. The source file prog2.cpp and your program execution screenshot in Visual Studio. Grading: This project is worth 25 points distributed as follows: Program Correctness (20 pts) Correct compilation and linking (5 pts) Correct computation (10 pts) Output displayed as specified (5 pts) Program Style (5 pts) Meaningful variable names (2 pts) Proper indentation (1 pt) Sufficient comments (2 pts) Sample Executions: Enter the maximum number to pick: 10 You odds of winning are 120:1 in lotto. You odds of winning are 150:1 in powerball. Press any key to continue.. Enter the maximum number to pick: 20 You odds of winning are 1140:1 in lotto. You odds of winning are 1266:1 in powerball. Press any key to continue. ** Anything typed in blue indicates a user input

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Can correlations show curvilinear relationships?

Answered: 1 week ago