Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( b ) You are given a file called namesBirthYears.txt that contains the names and birth years of individuals. For example, the file namesBirthYears.txt might
b You are given a file called namesBirthYears.txt that contains the names and birth years of individuals. For example, the file namesBirthYears.txt might be:
Hermann Weyl
Albert Einstein
Ernest Rutherford
Karen Uhlenbeck
Niels Bohr
Enrico Fermi
Stephen Hawking
Each line contains a first name, a last name, and a birth year in that order. Consecutive items in a line are separated by one or more white spaces.
Complete the following program that reads from this file and prints out the names and birth years in this file in the order of most recent to least recent birth years. If several individuals are born in the same year, their names should appear in the output in alphabetical order by last name, followed by first name. For the input file shown above, the required output is shown in the example below. Note each line in the output contains the last name, immediately followed by a comma, then a single space, then the first name, a single space, and then the birth year.
Hawking, Stephen
Uhlenbeck, Karen
Fermi, Enrico
Bohr, Niels
Weyl, Hermann
Einstein, Albert
Rutherford, Ernest
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started