Exercise Suppose you are given a text file, named "all_patients.txt", storing the name, the gender and the age of patients, in the format below. Abby Branch F 34 Alejandro Branch M 34 Allen Goldstein M 41 Amy Pearson F 36 <<< Which are in all patients.txt The name, the gender and the age of each row are delimited by a tab (^\t') character, while each line ends with the newline ('\n') character. M M Your task is to write a program that can read the file "all_patients.txt", process each record to complete the following requirements: Requirement 1: Formulate an account name for each patient, with format "”, where all characters in the account name are lower case letters. For example, if the name of the patient is "Abby Branch", the account name is "abranch". Requirement 2: Assign an account holder for each patient based on the following rules: Gender of patients Age of patients Account holder Younger than or equal to 30 John 31 - 40 Peter

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter9: Getting Started With Javascript: Creating A Countdown Clock
Section: Chapter Questions
Problem 5CP3
icon
Related questions
Question

Please help with this exercise I found on the internet. I want to know the solution, also with explaining( can use # in the coding), which includes the main and extra parts. Thanks a lot for helping

Exercise
Suppose you are given a text file, named “all_patients.txt", storing the name, the
gender and the age of patients, in the format below.
Abby Branch F
34
Alejandro Branch M
Allen Goldstein M
Amy Pearson
F 36
34
41
Which are in all patients.txt
The name, the gender and the age of each row are delimited by a tab ('\t') character, while
each line ends with the newline ('\n') character.
M
M
Your task is to write a program that can read the file "all_patients.txt", process each
record to complete the following requirements:
Requirement 1: Formulate an account name for each patient, with format “<first letter
of a given name><surname>”, where all characters in the account name are lower case
letters. For example, if the name of the patient is "Abby Branch", the account name is
"abranch".
Requirement 2: Assign an account holder for each patient based on the following rules:
Age of patients
Gender of patients
Account holder
Younger than or equal to 30
31 - 40
John
Peter
1
Transcribed Image Text:Exercise Suppose you are given a text file, named “all_patients.txt", storing the name, the gender and the age of patients, in the format below. Abby Branch F 34 Alejandro Branch M Allen Goldstein M Amy Pearson F 36 34 41 Which are in all patients.txt The name, the gender and the age of each row are delimited by a tab ('\t') character, while each line ends with the newline ('\n') character. M M Your task is to write a program that can read the file "all_patients.txt", process each record to complete the following requirements: Requirement 1: Formulate an account name for each patient, with format “<first letter of a given name><surname>”, where all characters in the account name are lower case letters. For example, if the name of the patient is "Abby Branch", the account name is "abranch". Requirement 2: Assign an account holder for each patient based on the following rules: Age of patients Gender of patients Account holder Younger than or equal to 30 31 - 40 John Peter 1
M
F
F
F
Older than 40
Younger than or equal to 30
31 - 40
Older than 40
Abby Branch F 34 abranch Kathy
Alejandro Branch M 34 abranch Peter
Allen Goldstein M 41 agoldstein
Amy Pearson F 36 apearson Kathy
Mary
Mary
Sam
Requirement 3: Write a file named "account_info.txt" that contains lines as shown below,
with the account name and the account holder appended to the record of each patient. Use "\t" as
the delimiter and "\n" as the newline character.
*Extra Part*
Kathy
Mandy
<<They are in account_info.txt>>
Requirement 4: If the file “all_patients.txt" is not found in the same directory of the
program, the program should print a message "File Not Found!".
For the account name above, if an account name already exists, use an account name
appended with an integer to distinguish different account names. For example, if there are
three patients with the same account name “abranch”, the second one should be named as
"abranch1" and the third one should be named as "abranch2".
Transcribed Image Text:M F F F Older than 40 Younger than or equal to 30 31 - 40 Older than 40 Abby Branch F 34 abranch Kathy Alejandro Branch M 34 abranch Peter Allen Goldstein M 41 agoldstein Amy Pearson F 36 apearson Kathy Mary Mary Sam Requirement 3: Write a file named "account_info.txt" that contains lines as shown below, with the account name and the account holder appended to the record of each patient. Use "\t" as the delimiter and "\n" as the newline character. *Extra Part* Kathy Mandy <<They are in account_info.txt>> Requirement 4: If the file “all_patients.txt" is not found in the same directory of the program, the program should print a message "File Not Found!". For the account name above, if an account name already exists, use an account name appended with an integer to distinguish different account names. For example, if there are three patients with the same account name “abranch”, the second one should be named as "abranch1" and the third one should be named as "abranch2".
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning