Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions