r/learnjava • • Oct 08 '17

Programing Assignment Help

My professor doesn't teach us since she expects us to know how to do everything although I'm taking an intro class in java. Anyway, any help is appreciated. This is the assignment itself https://imgur.com/a/iT0Wq I have some ideas on how to do this problem but no way of actually knowing how to do them because of my professor. This is a link to the code I wrote on pastebin https://pastebin.com/GjUiZnnb. I tried to make one array with the entire input but the space is considered another input instead of a white space. There's a lot that needs to be done and I don't really know where to even start. Any help is super appreciated, thanks.

1 Upvotes

5 comments sorted by

View all comments

1

u/smhanes Oct 08 '17

The number of students is the array size. Look at java arrays tutorials on how to create and add elements.

That number is also the number of times you'll run your loop. Each loop iteration should split the string on the space, calculate the length of each of the two substrings, pad accordingly, and then add them to the array you created.

This process of course will have to be modified in accordance with what is meant by input... Such as, are you actually given a text file, is input in the form of cli arguments passed in during runtime, is input requested from the command line during runtime..