Exception in thread "main" java.util.NoSuchElementException

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 339 Views - Last Post: 04 February 2012 - 02:41 PM Rate Topic: -----

Topic Sponsor:

#16 GregBrannon  Icon User is online

  • Ready for water skiing!
  • member icon

Reputation: 1067
  • View blog
  • Posts: 2,701
  • Joined: 10-September 10

Re: Exception in thread "main" java.util.NoSuchElementException

Posted 04 February 2012 - 02:41 PM

Okay. Back to basics.

Note that you have two while loops to read data from the file. The first while loop reads everything the file has to offer. The second while loop has nothing left to read and is skipped. You don't need two while loops. If you combine the two while loops into the first, you'll be fine.

Another problem, while the while loop is collecting the data from the file, i remains constant. The data collected from the file is all stored in array index 0, each on top (replacing) the previous.

Line 27, where you intended to sum the grades, is misplaced (too early) and then useless because of the problem above.

Fix those things, and there will be more. Try to fix any other problems that you can, but come back when you need more help, posting your updated code.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2