Write a method called mostCommonNames that accepts a Scanner representing an input file with names on each
Question:
Write a method called mostCommonNames that accepts a Scanner representing an input file with names on each line separated by spaces. Some names appear multiple times in a row on the same line. For each line, print the most commonly occurring name. If there’s a tie, use the first name that had that many occurrences; if all names are unique, print the first name on the line. For example, if the file has this input:
For the input above, your method should produce the following output:
Most common: Kim
Most common: Jamie
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Building Java Programs A Back To Basics Approach
ISBN: 9780135471944
5th Edition
Authors: Stuart Reges, Marty Stepp
Question Posted: