Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
Book Icon
Chapter 3, Problem 15PP

The Social Security Administration 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 for 2009 are stored in the file LifeDeathProbabi1ity. txt, which is included on the website for the book. There are three values for each row: the age, the death probability for a male, and the 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

The interpretation for the fourth line is that a 3-year-old female has a 0.000186 chance of dying during year 3 to 4.

Write a program that inputs an age and sex from the keyboard in the main function. The main function should call a function named simulate (that you must write), sending in the age and sex as parameters. The function should simulate to what age a person will live by starting with the death probability for the given age and sex. You can do this by reading the data from the file row by row. Skip rows that are less than the input age. Once the input age is reached, generate a random number between 0 and 1, and if this number is less than or equal to the corresponding death probability, then predict that the person will live to the current age and return that age. If the random number is greater than the death probability, then increase the age by one and repeat the calculation for the next row in the file.

If the simulation reaches age 120, then stop and predict that the user will live to 120. The main function should output the simulated age at which the person will die. This program is merely a simulation and will give different results each time it is run, assuming you change the seed for the random number generator.

Blurred answer
Students have asked these similar questions
In the attached file, you will find the oil production for all countries that produce more than 1Mbpd, use pie chart and bar chart to show the percentage of production for each of them. country bpd United States 11567000 Russia 10503000 Saudi Arabia 10225000 Canada 4656000 Iraq 4260000 China 3969000 United Arab Emirates 2954000 Brazil 2852000 Kuwait 2610000 Iran 2546000 Kazakhstan 1937000 Norway 1744000 Mexico 1733000 Qatar 1297000 Nigeria Libya Angola 1258000 1220000 1158000
BEFPULSEMIN 70 75 80 82 65 75 74 73 65 67 80 72 69 81 82 83 68 73 74 76 81 64 85 65 66 62 81 82 74 71 72 76 79 80 84 85 73 68 68 67 68 75 77 72 76 78 82 67 80 76 74 77 73 74 72 76 74 81 75 70     TATISTICSSTUDENTSSURVEYFORR contains the column BEFPULSEMIN (a numerical variable that measures student pulses before completing an online survey). For education purposes, consider this dataset to be a sample of size 60 taken from a much wider population for statistics students. Use R to find a 99% confidence interval for the mean of the population. Choose the most correct (closest) statement below. a. Your confidence interval is (72.38912, 76.41088) beats per minute and it is narrower than a 90% confidence interval created from this data. b. Your confidence interval is (72.88831, 75.91169) beats per minute and is narrower than a 90% confidence interval. c. Your…
The Apgar Medical group keeps a patient file for each doctor in the office. Each record contains the patient's first and last name, home address, and birth year. The records are sorted in ascending birth year order. Write a program so that display a count of the number of patients born each year John Hanson, 23 Elm, 1927Mary Locust, 476 Maple, 1950Susan Monroe, 512 Peachtree, 1957Carol Fortune, 2819 Locust, 1960James Fortune, 2819 Locust, 1963Lawrence Fish, 12 Elm, 1968Janice Weiss, 234 Birch, 1971Henry Garza, 199 Second, 1973Kimberly Swanson, 310 Appletree, 1980Louis Claude, 2716 Third, 1981Jill Fox, 12 Oak, 1985Opal Reynolds, 78 County Line, 1987Francis Dumas, 67 Fourth, 1992Madison Conroy, 23 Fifth, 1996Daniel Moy, 100 Sunset, 1987

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License