posted 12 years ago
No, that will not work. You have a serious logic error.
The advice was good, but it would have been better to say
1: Record the name2: Add each value to a sum and count the values3: Divide the total by the count4: Display the result.Never, never use == true or == false or anything similar. Not only are they poor style, but they are error‑prone too; you might write = by mistake. It is simply while (myScanner.hasNextInt())) …
Your reading from the keyboard ought to be in a method by itself, preferably in a different class. Actually you would need two methods.
It is also unfortunate that you have been told to take the details from the screen and print the average. Think how much more object‑oriented it would have been to create a Student object which has fields for name, results etc., and can calculate the average for itself.