1

I've been currently assigned to read from a .txt, and make a structure with what I've read. This is an example of what I should read:

Name1$Surname1$Programming&5.0#Mathematics&6.5#Algebra&7.2#History&6.7#Biology&6.9

I have no problems whatsoever when it comes to read the first two strings, however, from that point on i don't know how to manage, in order to properly split it and make new objects with them.

Any tips/ suggestions on how to do it pls?

Farzad Vertigo
  • 2,458
  • 1
  • 29
  • 32
  • It would be helpful to know what language you are using to read from .txt. Also please paste code on what you have already tried. – Pranay Aryal Jan 21 '19 at 03:13
  • Welcome to stackoverflow.com. Please take some time to read the [help pages](https://stackoverflow.com/help), especially the sections named "[What topics can I ask about here?](https://stackoverflow.com/help/on-topic)" and "[What types of questions should I avoid asking?](https://stackoverflow.com/help/dont-ask)". Also please [take the tour](https://stackoverflow.code/tour) and [read about how to ask good questions](https://stackoverflow.com/help/how-to-ask). Lastly please read [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). – 萝莉w Jan 21 '19 at 03:15
  • You just need to find the pattern. You have a name and surname. After that you have a list of courses, each having a grade value. You should have a look at the `split()` and `join()` functions in Java. You can concatenate these functions if needed. – K F Jan 21 '19 at 04:17

1 Answers1

0

Weird structure.

  1. Split at '$'
  2. First element of that split is the Name, second the Surname.
  3. Split the third element at '#'.
  4. Split each element of the result of step 3 again at '&' to get course and grade.

See here how to split strings.

leftbit
  • 848
  • 1
  • 7
  • 18