Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.io.*; import java.util.*; public class ReadFactors { public static v

ID: 3613520 • Letter: I

Question

import java.io.*;

import java.util.*;

publicclass ReadFactors

{

publicstatic voidmain(String[] args)

{

File factors =new File("Factor List");

int filefac;

int counter=1;

int i;

int factor;

try

{

Scanner scanner =new Scanner(factors);

while(scanner.hasNextInt())

{

filefac =scanner.nextInt();

System.out.println("Case #"+counter+": "+filefac+

" has these factors:");

for(i=2;i< filefac; i++)

{

if(filefac%i==0)

{

factor=i;

System.out.print(factor+" ");

}

}

counter++;

}

}

catch(FileNotFoundException e)

{

System.out.println("File not found");

}

}

Case #3: 20 has thesefactors:

2 4 5 10 Case #4: 54has these factors:

2 3 6 9 18 27 Case#5: 12 has these factors:

2 3 4 6 Case #6: 100has these factors:

2 4 5 10 20 2550

Explanation / Answer

You have a println() in the wrong place. (You're printing anew line). Your print statements should look like the following: System.out.print("Case#"+counter+": "+filefac+" has these factors:"); for(i=2;i