The Social Security A dministration maintains an actuarial life table that contains the probability that a person in the United States will die (http:// www.ssa.gov/OACT/STATS/table4c6.html). The death probabilities from this table for 2009 are stored in the file LifeDeathProbability.txt that is included with the book’s source code. There are three values for each row the age, death probability for a male, and death probability for a female. For example, the first five lines are:
0 | 0.006990 | 0.005728 |
1 | 0.000447 | 0.000373 |
2 | 0.000301 | 0.000241 |
3 | 0.000233 | 0.000186 |
4 | 0.000177 | 0.000150 |
This says that a 3-year-old female has a 0.000186 chance of dying that year.
Write a program that simulates how long you will live. The basic idea is to generate random numbers for each age until you “die.” For example, if you are a 1-year-old male, then if a random number is ≤ 0.000447 then the simulation will say you will live to age 1. Otherwise if the random number is > 0.000447 then go to age 2 and generate another random number. If it is<0.000301 then the simulation will say you will live to age 2, etc. The program should input your sex and age to determine which probabilities to use. The program should then simulate to what age you will live by starting with the death probability for the age and sexentered in the file. If the simulation reaches age 120 then stop and predict that the user will live to 120. This program is merely a simulation and will give different results each time it is run.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.