Question: Assuming the variable named input is a Scanner attached to the file temps.txt in the following statement: System.out.println ( Arrays . toString ( method

Assuming the variable named input is a Scanner attached to the file "temps.txt" in the
following statement:
System.out.println(Arrays.toString(method3(input)));
what output is produced based on the return value from the following method (see file
'temps.txt' below)?
public static int[] method3(Scanner in){
int [] myList ={,,,,,,,,,,};
while (in.hasNextLine()){
String line = in.nextLine ();
Scanner s= new Scanner(line);
while (s.hasNext ()){
if (s.hasNextInt ()){
int num = s.nextInt ()%10;
myList [num]++;
} else {
s.next ();
}
}
}
return myList;
}
# Code ends above, sample file temps.txt below:
Alabama Montgomery 22
Alaska 163 Juneau
73 Arizona Phoenix
3 Arkansas Little_Rock
California Sacramento 10
Colorado Denver 15
Connecticut Hartford 14
Delaware 41 Dover
1,2,1,2,1,2,0,0,0,0,0
1,1,2,1,2,1,0,0,0,0,0
1,0,2,1,3,1,0,0,0,0,0
1,2,1,1,1,1,0,0,0,0,0
1,1,1,3,1,1,0,0,0,0,0
The correct output is not listed here.
 Assuming the variable named input is a Scanner attached to the

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!