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.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Absolute C++
Additional Engineering Textbook Solutions
Software Engineering (10th Edition)
Java How To Program (Early Objects)
Computer Systems: A Programmer's Perspective (3rd Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Concepts of Programming Languages (11th Edition)
- The accompanying Gradebook spreadsheet contains a partially completed spreadsheet model for computing and summarizing the grades for a class. Complete the spreadsheet model by entering and copying the formulas in the appropriate cells. Cell range H4:H17 should contain the course number grades using the grades from exams and homework assignments and the grade allocation in row 22. Cell range I4:I17 should contain the course letter grades based on the grading criteria in cell range K4:L8. Rows 19, 20, and 21 should contain the average, maximum, and minimum exam, homework, and course number grades. You should only enter each formula once and copy the formulas to other cells. Gradebook Student ID Exam 1 Exam 2 Exam 3 Homework 1 Homework 2 Homework 3 Course Number Grade Course Letter Grade Grading Criteria 000-01-5562 60 50 40 79 92.0 76 0 F 000-01-2667 80 71 70 84 81.0 90 60 D 000-01-7376 65 65 65 60 90.0 94 70 C 000-01-1986…arrow_forwardThe file london_weather.csv contains weather data for the years 1979 to 2020. The first five lines of this file are: date,cloud_cover,sunshine,global_radiation,max_temp,mean_temp,min_temp,precipitation,pressure,snow_depth19790101,2,7,52,2.3,-4.1,-7.5,0.4,101900,919790102,6,1.7,27,1.6,-2.6,-7.5,0,102530,819790103,5,0,13,1.3,-2.8,-7.2,0,102050,419790104,8,0,13,-0.3,-2.6,-6.5,0,100840,2 Note, in particular, that the dates are given as eight-digit integers in the format YYYYMMDD. There appears to be some inconsistencies in this data, as there are rows for which the column max_temp contains an entry that is smaller than the corresponding entry in min_temp. Write a Python function wrong_temperature(year) that returns the number of days in a given year for which the column max_temp contains an entry that is smaller than the corresponding entry in the column min_temp.arrow_forwardList items have an index number. In the following list, which item has the index number of 3? ["John", "Harry", "Jesse", "John", "Harry", "Harry"] Select one: a. None O b. "John" O c. "Jesse" O d. "Harry"arrow_forward
- The distinction between MonthCalender and DateTimerPicker is explained below.arrow_forwardPythonarrow_forward123 4 5 6 7 8 A B Paper Type Name Letter Stock 65lb Cover Stock Premium White Copy Paper 2 Hole punch Letter Ultra-White Cardstock C Quantity 100 17 25 66 87 DE Discount 25% 5% 10% 15% 20% F Order Discounts G Minimum Quantity Discount 0 25 50 75 100 5% 10% 15% 20% 25% In the above spreadsheet, create a formula in cell D4 that uses the VLOOKUP function with the table array $F$4:$G$8. The formula will determine the applicable discount for each paper type order. You should be able to autofill this formula down through cells D4:D8.arrow_forward
- # Create Custom Transformer Create a custom transformer, just as we did in the lecture video entitled "Custom Transformers", that performs two computations: 1. Adds an attribute to the end of the numerical data (i.e. new last column) that is equal to $\frac{x_1^3}{x_5}$ for each observation. In other words, for each instance, you will cube the $x_1$ column and then divide by the $x_5$ column. 2. Drops the entire $x_4$ feature column if the passed function argument `drop_x4` is `True` and doesn't drop the column if `drop_x4` is `False`. (See further instructions below.) You must name your custom transformer class `Assignment4Transformer`. Your class should include an input parameter called `drop_x4` with a default value of `True` that deletes the $x_4$ feature column when its value is `True`, but preserves the $x_4$ feature column when you pass a value of `False`. This transformer will be used in a pipeline. In that pipeline, an imputer will be run *before* this transformer. Keep…arrow_forward2. 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 Мexico 1733000 Qatar 1297000 1258000 Nigeria Libya 1220000 Angola 1158000arrow_forwardThe file winning_numbers.txt contains the winning numbers for the Powerball lottery since the beginning of the year. Below is a partial listing of the file winning_numbers.txt: Drawing Date Winning Numbers Prize 1/1/2022 6 12 39 48 50 7 2 500000000 1/3/2022 2 13 32 33 48 22 2 540000000 1/5/2022 6 14 25 33 46 17 2 630000000 1/8/2022 20 21 36 60 65 13 10 20000000 1/10/2022 14 17 18 21 27 9 2 27000000 1/12/2022 12 21 22 30 33 24 4 38000000 1/15/2022 3 18 37 51 59 13 2 48000000 1/17/2022 9 24 35 46 65 22 2 53000000 1/19/2022 11 15 43 55 61 10 3 62000000 1/22/2022 8 14 33 36 67 17 2 76000000 The winning numbers for the date 1/1/2022 are: 6 12 39 48 50 7 2 The numbers 6 12 39 48 50 are considered the 5 white balls (ping pong balls with numbers on them), 7 is considered the Powerball (color is a red ping pong ball with a number on it), and 2 is considered the Powerball Multiplier. A player of the game wants to know which white balls have been selected with the greatest frequency and which…arrow_forward
- The names and student numbers of students are save in a text file called stnumbers.txt. Example of the content of the text file: Peterson 20570856 Johnson 12345678 Suku 87654321 Westley 12345678 Venter 87654321 Mokoena 79012400 Makubela 29813360 Botha 30489059 Bradley 30350069 Manana 30530679 Shabalala 28863496 Smith 87873909 Nilsson 30989698 Makwela 30256607 Govender 30048117 Ntumba 30598303 Ramsamy 29952239 Skosana 29982995 Jameson 30228484 Xulu 29092248 Wasserman 27469352 Bester 28615425 Babane 27154033 Maboya 29897890 Mahlangu 30031338 Majavu 30165970 Myene 30954177 Motaung 30907276 Ramaroka 30804507 Radebe 30007674 Sekake 30017416 Zwane 30038227 Shuro 30238072 Viljoen 28881389 Sithole 45688555 Write a function called displayData() to receive the array and number of elements as parameters and display the names and student numbers of the students with a heading and neatly spaced. Write a function, isValid(), which receives a number as parameter and determines whether the number…arrow_forwardFix the following m file: Submit fixed m file and histogram jpg created % Compute the average of some temperature data % Then plot the data in a MATLAB plot window % clc;clear n = 50; % number measurements temps = floor(50*rand(1,n))+50; time = 0:1:50; average = sum(temp)/length(temps); plot(time,temps) title('Temperature Measurements','fontsize',18,) xlabel('Time in minutes') ylabel('Temperature in degrees F') disp(averag)arrow_forwardIn the EWB there is a hidden range of data representing invoices created in late 2021 and early 2022 for a company call NorthWind. Each column in this range was named using create from selection tool. From this table calculate the gross profit for all units sold following the instructions below: - Use an array formula. - The columns that you will need are named: o UnitPrice (revenue per unit) o Quantity (Number of units sold) o ProductStandardCost (Cost for one unit) - You may not use the SUMPRODUCT function. - Use the ROUND() function to round your formula to 2 decimal places. - Copy the answer and the formula into the canvas exam (including the equal sign). Answer: Formula:arrow_forward
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L