Concept explainers
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 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 live to age 1. Otherwise if the random number is > 0.000447 then go to the 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 sex entered 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.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++: Early Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Modern Database Management
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Mechanics of Materials (10th Edition)
- pizzaStats Assignment Description For this assignment, name your R file pizzaStats.R For all questions you should load tidyverse and lm.beta. You should not need to use any other libraries. Load tidyverse with suppressPackageStartupMessages(library(tidyverse)) Load lm.beta withsuppressPackageStartupMessages(library(lm.beta)) Run a regression predicting whether or not wine was ordered from temperature, bill, and pizza. Assign the coefficients of the summary of the model to Q1. The output should look something like this: Estimate Std. Error z value Pr(>|z|)(Intercept) -1.09 1.03 -1.06 0.29temperature -0.04 0.01 -3.20 0.00bill 0.03 0.01 3.75 0.00pizzas 0.19 0.06 3.27 0.00 Here is the link of the pizza.csv https://drive.google.com/file/d/1_m2TjPCkPpMo7Z2Vkp32NiuZrXBxeRn6/view?usp=sharingarrow_forwardIn Python Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements: Each row contains the title, rating, and all showtimes of a unique movie. A space is placed before and after each vertical separator ('|') in each row. Column 1 displays the movie titles and is left justified with a minimum of 44 characters. If the movie title has more than 44 characters, output the first 44 characters only. Column 2 displays the movie ratings and is right justified with a minimum of 5 characters. Column 3 displays all the showtimes of the same movie, separated by a space. Each row of the CSV file contains the showtime, title, and rating of a movie. Assume data of the same movie are grouped in consecutive rows. Ex: If the input of the program is: movies.csv and the contents…arrow_forwardIn java program, please find out the total population for United Kingdom with data that store in text file. The program also should able to display how much average new born per day based the dataset for country specify by user.Text file: (actual file have 500 rows and more country)country,date,total_population,new_born, new_deathUnited Kingdom, 2020-02-24, 63475839, 354, 34,Afghanistan, 2020-02-24, 56213485, 524, 29,United Kingdom, 2020-02-24, 63475702, 602, 56,Afghanistan, 2020-02-25, 56213954, 601, 65,arrow_forward
- Chapter 7 - Programming Challenge 15 15. World Series Champions If you have downloaded this book’s source code (the companion Web site is available at www.pearsonhighered.com/gaddis), you will find a file named WorldSeriesWinners.txt. This file contains a chronological list of the winning teams in the World Series from 1903 through 2009. (The first line in the file is the name of the team that won in 1903, and the last line is the name of the team that won in 2009. Note that the World Series was not played in 1904 or 1994, so those years are skipped in the file.) Write a program that lets the user enter the name of a team, and then displays the number of times that team has won the World Series in the time period from 1903 through 2009. Tip: Read the contents of the WorldSeriesWinners.txt file into an ArrayList. When the user enters the name of a team, the program should step through the ArrayList, counting the number of times the selected team appears You only need to submit the…arrow_forwardA temperature file consists of five records, each containing a temperature in degrees Fahrenheit. A program is to be written that will read the input temperature, convert it from degrees Fahrenheit to degrees Celsius and print both temperatures in two columns on a report. Column headings, which read ‘Degrees F’ and ‘Degrees C’, are to be printed at the top of the page. What ist he best solution algorithm to successfully implement the above question?arrow_forwardThis is a python File Create a program that presents a menu with these options: Add product Sort by quantity (low to high) Print Inventory Quit Read the initial product information from a text file. Remember to ask the user to enter the filename & make sure it exists! The program should NOT product an error if the file isn’t there! Store the product information into a DICTIONARY called prodDict. The dictionary should map the productID (the key for the dictionary) to a LIST that contains description, unitPrice, and quantity. The text file will be structured as shown below, where each line contains the product id, product description, unitPrice and quantity.NOTE: Each entry on the line is separated by a comma and a space. Example textfile: 111, arm chair, 99.99, 5444, desk, 10, 40777, lamp, 20, 5333, credenza, 50.98., 20222,bassinet , 5.59, 10 Example of the empDict after the information shown has been readd and stored:{ 111: [“George Gray”, 10, 40], 222: [“Amy Abrahmson”,…arrow_forward
- In python please! I am strugglingarrow_forwardA Personal Fitness Tracker is a wearable device that tracks your physical activity, calories burned, heart rate, sleeping patterns, and so on. One common physical activity that most of these devices track is the number of steps you take each day. The steps.txt file contains the number of steps a person has taken each day for a year. There are 365 lines in the file, and each line contains the number of steps taken during a day. (The first line is the number of steps taken on January 1st, the second line is the number of steps taken on January 2nd, and so forth.) Write a program that reads the file, then displays the average number of steps taken for each month. (The data is from a year that was not a leap year, so February has 28 days.) You don't need to see the file , Just write a code using the "file" like this def main(): with open("steps.txt", "r") as file:arrow_forwardJavascript: Using the data set as a pre-defined variable in your program, write code that uses the dataset to print the FIRST NAMES ONLY of people who have BOTH above average English grades AND below average age from the dataset. var dataSet = [ { "name":"Maura Glass", "age":60, "math":97, "english":63, "yearsOfEducation":4 }, { "name":"James Gates", "age":55, "math":72, "english":96, "yearsOfEducation":10 }, { "name":"Mills Morris", "age":26, "math":83, "english":77, "yearsOfEducation":10 }, { "name":"Deena Morton", "age":57, "math":63, "english":63, "yearsOfEducation":10 }, { "name":"Edith Roth", "age":38, "math":79, "english":94, "yearsOfEducation":10 }, { "name":"Marva Morse", "age":31, "math":93, "english":78, "yearsOfEducation":9 }, { "name":"Etta Potts", "age":48, "math":57, "english":93, "yearsOfEducation":7 }, { "name":"Tate Moss", "age":22, "math":83, "english":64, "yearsOfEducation":8 }, { "name":"Sanders Burris", "age":27, "math":65, "english":66, "yearsOfEducation":5…arrow_forward
- Using Pandas library in python - Calculate student grades project Pandas is a data analysis library built in Python. Pandas can be used in a Python script, a Jupyter Notebook, or even as part of a web application. In this pandas project, you’re going to create a Python script that loads grade data of 5 to 10 students (a .csv file) and calculates their letter grades in the course. The CSV file contains 5 column students' names, score in-class participation (5% of final grade), score in assignments (20% of final grade), score in discussions (20% of final grade), score in the mid term (20% of final grade), score in final (25% of final grade). Create the .csv file as part of the project submission Program Output This will happen when the program runs Enter the CSV file Student 1 named Brian Tomas has a letter grade of B+ Student 2 named Tom Blank has a letter grade of C Student 3 named Margo True has a letter grade of A Student 4 named David Atkin has a letter grade of B+ Student 5 named…arrow_forwardFill in the loop table with the correct values, Each row should represent the values of the variables at the line with the comment LOCATION. You don't necessarily need to fill out all of the rows on the provided fable. If you don't fill up the whole table, that isn't necessarily wrong! 1 - 2 a - 10 name - 'AL' while i < 9: if name 'AL': 1: 2 nam AL intinl else: if name < 'NAPOLEON': name - 'NASH elif name < 'NATE': name - 'SAM' else: name- 'AL ' # LOCATIONarrow_forwardIn C++ Query the user for the name of a file. Open and process that file, reporting the number of words in the file and the number of words containing each letter, and the length of that word. Assume that any word exceeding nine characters is counted as a ten character word. If the same letter appears more than once, it is counted only once. The result should be a matrix of 26 rows (one row for each letter) and ten columns (one column for each word length (1-10), and the contents of the matrix must be displayed. As an example, assume the file contains only two words - “rotten” and “egg”. When processing “rotten”, rows for r, o, t, e and n would have the contents of column 6 incremented because “rotten” is a six letter word. When processing “egg”, rows for e and g would have the contents of column 3 incremented because “egg” is a three letter word.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning