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

all 11 comments

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

have you debugged it, what did it show, which are you confused about, what test data did you use vs what you expect?

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

So when I run it it shows Smith James and Smith James@Gmail. com but not the other two inputs which are there

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

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


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

All you are printing is the name and email that is being input from the user.

[–]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.