Question: The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name

The following code uses a Scanner object to read a text file called dogYears.txt. Notice that each line of this file contains a dog's name followed by an age. The program then outputs this data to the console. The output looks like this: Tippy 2 Rex 7 Desdemona 5 Your task is to use the Scanner methods that will initialize the variables name1, name2, name3, age1, age2, age3 so that the execution of the three println statements below will result in the desired output. String name1, name2, name3; int age1, age2, age3; Scanner inputData = new Scanner(new FileReader("dogYears.txt"));

CODE GOES HERE

System.out.println(name1+" "+age1); System.out.println(name2+" "+age2); System.out.println(name3+" "+age3);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!