Programming Language: Java 8 application using lambda and streams. NO expression
ID: 3825466 • Letter: P
Question
Programming Language: Java 8 application using lambda and streams. NO expressions such as while or for loops
Objective: Reads two input files: One file which stores information about the counties, states, zip code. And the other file stores information about people's firstName, lastName, income, zipcode. Narrow the information down to Virginia (“VA”), calculate the average income in each county, and then print all people along with their income relative to their county average.
Note: The input will consist of two text files. The paths to these files (first: counties, second: people) should be passed to the java application using command-line arguments,
e.g. java javaFileName counties.txt people.txt
Files Example:
Counties file: Each line consists of three pieces of information describing a zip-code area, separated by commas: COUNTY,STATE_ABBREV,ZIPCODE For example,
counties.txt:
People file: Each line consists of four pieces of information describing a person, separated be commas: FIRST_NAME,LAST_NAME,INCOME,ZIPCODE. For Example,
People.txt:
Note: Income will be a positive integer. The combination (First Name, Family Name, ZIP code) will uniquely describe each line, i.e., there will be no two lines that have the same all three of the above. However, there may be e.g. two people with the same first and last names in two different ZIP code in the same county.
Output
Please remember that this is done in Java 8 so use of streams and lamdas instead of classical loops. Thank you.
Henrico, VA,23229 Henrico, VA, 23228 Richmond, VA, 23284 Greensboro,NC, 27214Explanation / Answer
public NewClass(String a) {...}
public NewClass(String a, String b) {...}
public myMethod(Function<String, NewClass> fn) {...}
myMethod(str -> new NewClass(str));
myMethod(NewClass::new);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.