Java Programming Project 6: File I/O
Purpose: To practice reading from as well as writing to text files with the help of Scanner class methods, and PrintStream class methods. You will also learn to implement some simple Exception Handling.
Carefully examine and follow ALL the program specifications.
Take a look at the PPT slides for Chapter 7 File I/O for examples that will help with this program.
Hotel Expense Recording Keeping:
A hotel bookkeeper enters client hotel expenses in a text file. Each line contains the following, separated by semicolons: client name, service sold (i.e., Dinner, Conference, Lodging, etc.), the sales amount, and the date.
Attached (and below) is an example input file that your program will be tested with, so you will need to make sure that you program will run correctly using this file. Since this may be your first experience reading from an input file, you will likely find it easiest if you store the input file in the same folder with your Java program file so that they can easily communicate with one another. The easiest way to store this file is as a plain text file in Notepad (do not use MS word or any other sophisticated word processor or you will be processing embedded text commands, which is not at all recommended). Here is what the input file looks like:
Jason Inouye;Conference;250.00;11/10/2016
Jason Inouye;Lodging;78.95;11/10/2016
Mary Ryan;Dinner;16.95;11/10/2016
Mark Twain;Dinner;25.50;11/10/2016
Mark Twain;Spa;50.00;11/10/2016
Steven Hawking;Conference;250.00;11/10/2016
Steven Hawking;Room Service;45.00;11/11/2016
Steven Hawking;Lodging;78.95;11/11/2016
Ayrton Senna;Room Service;23.20;11/10/2016
Ayton Senna;Dinner;22.50;11/10/2016
Ayton Senna;Lodging;78.95;11/10/2016
One feature of the input file, is that it uses a semicolon (;) to delimit the tokens on each line of input, rather than whitespace. You will need to use a delimiter statement after you construct your line scanner object.
To see how to construct a line scanner object, go to Chapter 7 PowerPoint slide in the Week 13 folder. So for example, if you create an object called lineScan of type Scanner to process tokens on a given line of input, then you could call the useDelimiter method on your lineScan object, as follows:
lineScan.useDelimiter(";");
This will allow you to tokenize each input line based, not on white space delimiters, but using the semicolon as a delimiter instead.
This is what should be in your Output file after you run your program (this file will most likely be located in the same folder as your Java program).
Dinner expenses : 64.95
Lodging expenses : 236.85
Conference expenses : 500.00
Room Service expenses : 68.20
Spa expenses : 50.00
Submission Requirements:
In: Computer Science
A cohort study was undertaken to examine the association between high lipid level and coronary heart disease (CHD). Participants were classified as having either a high lipid level (exposed) or a low or normal lipid level (unexposed). Because age is associated with both lipid level and risk of heart disease, age was considered a potential confounder or effect modifier and the age of each subject was recorded. The following data describes the study participants: Overall, there were 11,000 young participants and 9,000 old participants. Of the 4,000 young participants with high lipid levels, 20 of them developed CHD. Of the 6,000 old participants with high lipid levels, 200 of them developed CHD. In the unexposed, 18 young and 65 old participants developed CHD.. Calculate the appropriate crude ratio measure of association combining the data for young and old individuals. 3. Now, perform a stratified analysis and calculate the appropriate stratum-specific ratio measures of association. What are they? 4. Do the data provide evidence of effect measure modification on the ratio scale? Justify your answer.
In: Advanced Math
A researcher followed a cohort for 10 years after the Aliso canyon gas spill. The researcher interviewed 290 residents. 140 residents lived within a 2 mile radius of the leak and were classified as exposed and 150 residents lived more than 5 miles away and were considered unexposed. In total 120 of the 140 residents exposed to the gas developed respiratory problems and 10 of the 150 not exposed to the gas developed respiratory problems.
|
Respiratory Problems |
No Respiratory Problems |
Total |
|
|
Exposed to Gas |
|||
|
Not Exposed to Gas |
|||
|
Total |
|
Question |
Answer |
|
1. What was the incidence of Respiratory Problems per 1000 in the exposed group? |
|
|
Interpretation 1: |
|
|
2. What was the incidence of Respiratory Problems per 1000 in the un-exposed group? |
|
|
Interpretation 2: |
|
|
3. Calculate a relative risk or risk ratio for this study and interpret this number. |
|
|
Interpretation 3: |
|
|
4. Calculate the Attributable Risk Percent/ Etiologic Fraction Percent and interpret this number. |
|
|
Interpretation 4: |
|
In: Statistics and Probability
Infertility treatment and Asthma: The millennium cohort study was set up as a nationally representative study of 18818 infants born from 2000-2002 in the UK who are followed up over time for different health outcomes. At the time of enrolment mothers were asked about conception history which was categorised into the following….
When the children reached the ages of 5 mothers were asked about asthma in the child with the following results…
|
Mother’s Group |
Total children |
Total children with Asthma * |
Cumulative Incidence rate (risk) |
|
2029 |
372 |
|
|
3650 |
570 |
|
|
6480 |
885 |
|
|
505 |
93 |
|
|
173 |
20 |
|
|
104 |
18 |
|
|
TOTAL |
12941 |
1958 |
*Asthma diagnosed at any age up until the age of 5.
Q9: Calculate the cumulative incidence rates (risk) of Asthma for the groups (and overall) and fill them in on the above table
Q10: Calculate the cumulative incidence ratio (relative risk) of asthma in children of those with an unplanned (group i) pregnancy compared to those with a planned pregnancy with time to conception <12 months (group iii).
Q11: The relative risk of asthma in children of mothers on infertility treatment compared to those with a planned pregnancy is 1.27 with a 95% confidence interval around this of 0.84 to 1.96. How would you interpret this result (consider the relative risk and the 95% CI)?
Q12: In the paper the authors adjust for the sex of the child in the analysis and this gives an estimate for the relative risk in Q11 of 2.10 with a 95% confidence interval of 1.16 to 3.81.
2. Can you give a possible reason why the RR might increase when adjusting for the child’s sex?
Q13: The analysis was repeated in 2013 looking at asthma diagnosed by age 10. Between age 5 and 10 a total of 2444 children had been lost to follow-up, but a date was known for the last follow up time for each child (e.g. for a child the survey was completed at age 8 but not after that).
Q14: What type of cohort study is this?
In: Statistics and Probability
A ["prospective", OR "retrospective"] cohort study is carried out to investigate the association between occupational arsenic inhalation and neurological exposure and neurological effects among workers in a copper smelter. For the sake of simplicity, let’s assume there are two possible exposure categories: high and low (for example, those working in the smelting process and those working in administration). The exposure was carefully assessed by review of company records which reflected very good exposure monitoring (both air sampling and urine testing). The outcome was based on self-reported information from an interview that asked: “Have you had tingling in your fingers in the last month that lasted more than 30 minutes?” Those that said “yes” were classified as “diseased”, and those that said “no” were the “non-diseased” group. In order to avoid ["information bias", OR "selection bias"] bias, the company encouraged everyone to participate by telling their workers that they were a concerned employer and wanted to know if there were adverse neurological effects from the potential arsenic exposure in some of the work areas.
The following is the resulting 2 x 2 table:
|
Diseased |
Not Diseased |
Total |
|
|
High Exposure |
60 |
100 |
160 |
|
Low Exposure |
40 |
350 |
390 |
|
Total |
100 |
450 |
550 |
In: Statistics and Probability
Problem 8: The Framingham Heart Study was a longitudinal cohort study of 5000+ men and women. One outcome of interest was fasting glucose levels. Glucose levels were categorized into three different categories:
Glucose Levels
-Diabetes (glucose >126),
-Impaired Fasting Glucose (glucose 100-125),
-Normal Glucose
Several possible risk factors were also recorded:
Risk Factors
-Sex
-Age
-BMI (normal weight, overweight, obese)
-Genetics
To determine if each possible risk factor is related to glucose levels,researchers need to use an appropriate hypothesis test.
Test Choices
1. ANOVA
2. Chi-Square GOF
3. Chi-Square test for independence
4. Test for equality of means
5. Test for equality of proportions
6. Other
a. What test would be used to assess whether the different sexes(male and female) have the same proportions of the different glucose levels?
b. What test would be used to assess whether the different glucose levels have the same mean age?
c. What test would be used to assess whether the different categories of BMI have the same proportions of the different glucose levels?
In: Math
Researchers conducted a cohort study of the association between air pollution and asthma. The
rate ratio was 8.0, when comparing those exposed to high levels of air pollution with those
exposed to low levels of air pollution. Which of the following issues should the researchers
consider when making their study conclusions and when thinking about causality? Choose all
that apply and explain your choice.
a) The rate ratio of 8.0 indicates a strong association, which lends support for causality
b) Strong confounding may actually be causing the strong association seen
c) Other studies of the same exposure—health outcome association reported rate ratios in the
range of 1.5-3.0, less than the rate ratio of 8.0 seen in this study
d) The temporal sequence of the exposure and outcome should be known in order to draw
accurate conclusion.
In: Biology
Imagine that you buy a new computer system with independent
components including a new desktop computer (with a CPU and a
graphics card), new software, and a new monitor. You want to play
games on the new system, but it runs games very slowly. You assume
that the keyboard and mouse are not creating the problem; so, to
figure out what is making the system run so slowly, you experiment
with combinations of your old equipment with the new equipment.
Here are your experiments and results:
Experiment 1: New computer, new software, and new monitor — and it
runs slowly.
Experiment 2: New computer, new software, and old monitor — and it
runs slowly.
Experiment 3: New computer, old software, and new monitor — and it
runs fast.
Experiment 4: New computer, old software, and old monitor — and it
runs fast.
Experiment 5: Old computer, new software, and new monitor — and it
runs fast.
Experiment 6: Old computer, new software, and old monitor — and it
slowly.
Experiment 7: Old computer, old software, and new monitor — and it
runs fast.
Experiment 8: Old computer, old software, and old monitor — and it
runs fast.
Based on this data, which experiment shows that the conjunction of
the new computer and the new software is NOT SUFFICIENT for the
system to run slowly?
In: Statistics and Probability
Imagine that you buy a new computer system with independent
components including a new desktop computer (with a CPU and a
graphics card), new software, and a new monitor. You want to play
games on the new system, but it runs games very slowly. You assume
that the keyboard and mouse are not creating the problem; so, to
figure out what is making the system run so slowly, you experiment
with combinations of your old equipment with the new equipment.
Here are your experiments and results:
Experiment 1: New computer, new software, and new monitor — and it
runs slowly.
Experiment 2: New computer, new software, and old monitor — and it
runs slowly.
Experiment 3: New computer, old software, and new monitor — and it
runs fast.
Experiment 4: New computer, old software, and old monitor — and it
runs fast.
Experiment 5: Old computer, new software, and new monitor — and it
runs fast.
Experiment 6: Old computer, new software, and old monitor — and it
slowly.
Experiment 7: Old computer, old software, and new monitor — and it
runs fast.
Experiment 8: Old computer, old software, and old monitor — and it
runs fast.
Based on this data, which experiment shows that the conjunction of
the new software and the old monitor is NOT SUFFICIENT for the
system to run slowly?
In: Advanced Math
In: Economics