Java: An Introduction to Problem Solving and Programming (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 10, Problem 4P

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.

Blurred answer
Students have asked these similar questions
# 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…
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=sharing
astfoodStats Assignment Description For this assignment, name your R file fastfoodStats.R For all questions you should load tidyverse, openintro, and lm.beta.  You should not need to use any other libraries. suppressPackageStartupMessages(library(tidyverse)) suppressPackageStartupMessages(library(openintro)) suppressPackageStartupMessages(library(lm.beta)) The actual data set is called fastfood. Continue to use %>% for the pipe. CodeGrade does not support the new pipe. Round all float/dbl values to two decimal places. All statistics should be run with variables in the order I state E.g., "Run a regression predicting mileage from mpg, make, and type" would be: lm(mileage ~ mpg + make + type...) To access the fastfood data, run the following: fastfood <- openintro::fastfood Create a correlation matrix for the relations between calories, total_fat, sugar, and calcium for all items at Sonic, Subway, and Taco Bell, omitting missing values with na.omit(). Assign the…

Chapter 10 Solutions

Java: An Introduction to Problem Solving and Programming (8th Edition)

Ch. 10.3 - Prob. 11STQCh. 10.4 - Write some Java code to create an output stream of...Ch. 10.4 - Give three statements that will write the values...Ch. 10.4 - Give a statement that will close the stream toFile...Ch. 10.4 - What import statement(s) do you use when creating...Ch. 10.4 - Prob. 16STQCh. 10.4 - Give three statements that will read three numbers...Ch. 10.4 - Give a statement that will close the stream...Ch. 10.4 - Can you use writeInt to write a number to a file...Ch. 10.4 - Can you use readUTF to read a string from a text...Ch. 10.4 - Prob. 21STQCh. 10.4 - Prob. 22STQCh. 10.4 - Does the class FileInputStream have a method named...Ch. 10.4 - Does the class FileOutputStream have a constructor...Ch. 10.4 - Does the class ObjectOutputStream have a...Ch. 10.4 - Prob. 26STQCh. 10.4 - Suppose that a binary file contains exactly three...Ch. 10.4 - The following code appears in the program in...Ch. 10.4 - Prob. 29STQCh. 10.5 - Prob. 30STQCh. 10.5 - Prob. 31STQCh. 10.5 - Prob. 32STQCh. 10.5 - Prob. 33STQCh. 10.6 - Prob. 34STQCh. 10.6 - Prob. 35STQCh. 10 - Write a program that will write the Gettysburg...Ch. 10 - Modify the program in the previous exercise so...Ch. 10 - Write some code that asks the user to enter either...Ch. 10 - Write a program that will record the purchases...Ch. 10 - Modify the class LapTimer, as described in...Ch. 10 - Write a class TelephoneNumber that will hold a...Ch. 10 - Write a class contactInfo to store contact...Ch. 10 - Write a program that reads every line in a text...Ch. 10 - Repeat the previous exercise, but write the new...Ch. 10 - Write a program that will make a copy of a text...Ch. 10 - Suppose you are given a text file that contains...Ch. 10 - Suppose that you have a binary file that contains...Ch. 10 - Suppose that we want to store digitized audio...Ch. 10 - Write a program RecoverSignal that will read the...Ch. 10 - Even though a binary file is not a text file, it...Ch. 10 - Write a program that searches a file of numbers...Ch. 10 - Write a program that reads a file of numbers of...Ch. 10 - The following is an old word puzzle: Name a common...Ch. 10 - The Social Security Administration maintains an...Ch. 10 - The following is a list of scores for a game....Ch. 10 - Write a program that checks a text file for...Ch. 10 - Prob. 5PPCh. 10 - Prob. 6PPCh. 10 - Revise the class Pet, as shown in Listing 6.1 of...Ch. 10 - Write a program that reads records of type Pet...Ch. 10 - Prob. 12PP

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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY