0

I am still somewhat new to Java programming and I have been given an assignment that asks to read names from a file and print them out that start with a letter lexicographically less than or equal to M followed by all of the names that start with a letter greater than M. Is there anyone that can help me with this?

An example would be that the file would contain

Fred Jane
Sam
Bill Nancy

and the print out on the screen would be:

1 Fred
2 Jane
3 Bill
4 Sam
5 Nancy

3
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by NormR1
0

What do you need help with?
The Scanner class will be useful with reading the file.
The String class has methods for comparing Strings.
The ArrayList class can hold Strings that need to be saved for later.

0

I don't know how to sort the names in the file lexicographically, since I don't understand the sorting, I don't know where to begin with the coding for it. I'm not familiar with ArrayList, I only know how to use a simple array.

0

Start with a simple program that reads the names and saves them in an array.

Your sample output doesn't have the names sorted. Just separated into two groups.

1

The instructions do NOT say to sort the input.
I read them to say that the input is to be separated into two groups. Those before or equal and those after "M"

Votes + Comments
aaaaaaaaahhhh right +1
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.