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.
hello, i was given an assigment to write a program that asks for the name of a roster file that has students names in it. Then the program promts for eacht students grade and with those grades does some calculations. At the end a table is outputted with the name of the student and the calculations. the program is include an array. My question is, how do i know how many students are in the file? is there some kind of method that counts the lines of the text file? this is my first few lines of the program
I wonder if "array" is part of the assignment. I'm guessing you want the number of students so you can allocate the array to the right size, and maybe again for the calculations - eg average or something.
There is a way around the array size problem, and that is to use a List. If you look up List in the JavaDoc you'll find it is an interface and there are several classes that implement List. You might do something like:
If you really have to have an array, you can get an array from the List. Look at List APIs again for hints.
Take small steps - make one thing work at a time. Feel free to post code as you go if you run into problems. Have fun!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi