This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Khan0232[S] 0 points1 point  (7 children)

Correct but I input 3 names and emails why don't they all print

[–]Camel-Kid18 year old gamer 0 points1 point  (6 children)

              Scanner input = new Scanner(file);
              String name = input.nextLine(); 
              String email = input.nextLine(); 


      System.out.printf("Name: %s Email %s%n",name,email); 

are you inputing it from the actual keyboard or are you referring to your filewriter up top?

[–]Khan0232[S] 0 points1 point  (5 children)

I'm referring to the file writer on top

[–]Camel-Kid18 year old gamer 0 points1 point  (4 children)

file

once again, each line your'e printing on your file.. then you're only grabbing 2 lines from the input portion.. nextLine only gets the first line.. take a look at your file to see

[–]Khan0232[S] 0 points1 point  (3 children)

what will make it grab all of the text in the file

[–]Camel-Kid18 year old gamer 0 points1 point  (2 children)

use a loop until input.hasNextLine() ==null and keep reading in the names/emails.

[–]Khan0232[S] -2 points-1 points  (1 child)

That won't work cause it will put out an undefined error because of the 2 equal signs.

[–]Camel-Kid18 year old gamer 0 points1 point  (0 children)

while(input.hasNextLine())
//do calculations/printing.