#My code does not input the file nor print the output

21 messages ยท Page 1 of 1 (latest)

loud marshBOT
#

โŒ› This post has been reserved for your question.

Hey @pure sparrow! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

oblique flare
#

is it displaying any error ?

pure sparrow
#

Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1371)
at StudentsManager.main(StudentsManager.java:49)
C:\Users\alawy\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)

oblique flare
#

check if the scanner has a next token by calling scanner#hasNext

#

I suppose the input file contains the commands ?

pure sparrow
#

yes it does

oblique flare
#

could you upload the input file

pure sparrow
#

i thought i uploaded it sorry second pls

oblique flare
#

Your first scanner.nextLine() consumes the entire first line Add student: ID1, Ahmed, CS101, 20 not only the Add student part.
What I would do:

while scanner has another line:
      read the line and store it in a variable
      using the line stored in the variable parse the command and execute it.

that way you keep interaction with the scanner to a minimum and it will be easier to parse the command.

pure sparrow
#

sorry i am a bit frustrated but i'm implementing what you suggested hopefully it will solve the issue

loud marshBOT
pure sparrow
oblique flare
#

at no point in the program you are writing to your output file. At the very end, after all commands are processed you iterate over the entirety of the Linked list write each Student to the output file

pure sparrow
#

I tried editing both classes if you may take a look

#

nothing happened

oblique flare
loud marshBOT
#

๐Ÿ’ค Post marked as dormant

This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping.
Warning: abusing this will result in moderative actions taken against you.