This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
After the great help I got on this forum from my last question, I am in DESPERATE need of your help again!!
I have been given a program to write, (bear in mind I've only been studying Java a month and haven't even been taught half of the stuff the program has to do yet!!!).It has to allow the user to input test marks, arrange them neatly in columns, store and save the data then reorganise delete and modify as needed.
So far I have managed to input the marks and format them using hte printf method. I thought i'd done ever so well, until someone mentioned that it had to use arrays and now I'm lost in the maze again. I'm the furthest ahead in my group but I feel so disorientated now. For the life of, I cannot find a way of inputting information, then arranging it so it can be stored, whilst also creating a loop so that inputted marks will be automatically arranged into a table!!! Pleeeeeeeeeeease help if you can!!!
you can set up an integer array by using int  A = new int ;
 = array symbol  = says your going to create an array of ten references to intergers. (since your counting from 0-9 not 1-9.. and to store the scores, you can use this. A = 100; A = 90; and so on....
But for the flexibility you're describing, I'm not sure that an array is your best option. (For one thing, the size of the array is set upon instantiation, so this isn't very friendly for insertions/deletions.) So you might want to look at the Java Tutorial on collections...
I agree with Marc. Unless you have been specifically told to use an array then read the collections tutorial he linked above and then consider using something such as an ArrayList (java.util.ArrayList).
This has two methods add() and remove() which should be quite useful to you.
Now, you can add() and remove() Strings to an ArrayList, but, depending on how much you have learn't about OO yet, you may wish to consider writing a new class to represent a test result entry - that way you can encapsulate each test mark in an object which you would then add to the ArrayList one-by-one. Each test-result object might hold values for the test mark, candidate name, date taken etc depending on the project requirements.
When you need to get the results back out to display them you can use a method called iterator() on the ArrayList object to loop over each test-result entry.
Originally posted by Justin bob: you can set up an integer array by using int  A = new int ;
 = array symbol  = says your going to create an array of ten references to intergers. (since your counting from 0-9 not 1-9..
 = says you're going to create an array of nine integers indexed from 0 to 8. [ November 09, 2005: Message edited by: Joanne Neal ]
Joined: Oct 29, 2005
Thank you all for your time! Been il lwith food poisoning but tried it today and it worked like a charm! You've all been so helpful, now I've got to get my head around String tokenizers and reading from the outputted file!!