Hello there. Could you give some insightful input into my problem:
My program is fed multiple lines of input. The input is composed of a name and two values of that person. Each line is of a new 'person' e.g.
"James 23 15.05
Lucy 51 25.523
Kam 42.4 21.54
Jak 85 242" etc.
There are two requirements:
- I must iterate through each line, and read the name, one by one. I won't know what the name is, but I will know how many names there are. I would iterate through it with a forloop.
- There must be some "key"-like variable or something, and this key will be associated with the name and the values.
What I have thought of:
A HashTable... but I ran into the problem where you cannot iterate through it easily like through a forloop.
A 2D array would be too cumbersome.
What would be a better solution to meet my requirements, and how would I use it?
(Even better... You may have noticed that each new line of input contains 3 values: the name, and two values. Is there something where I can map the three values? At the moment, my soon-to-be-replaced-with-something-else HashTable looks like this: hashT.add("James", "23 15.05") where the key James is associated with one value of "23 15.05". Is there something to enable me to key James with "23" AND "15.05"?)