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

Can please someone help me in doing this question, I posted this one previously

ID: 3588000 • Letter: C

Question

Can please someone help me in doing this question, I posted this one previously as well, be it's not answered.

Programming. #1c: 1. Random connections. Develop a UF client CoachTom.java that takes an integer value N from the command line, generates random pairs of integers between 0 and N-1, calling connected () to determine if they are connected and then union () if not (as in our development client), looping until all sites are connected, and printing the number of connections generated. Package your program as a statioc method count () that takes N as argument and returns the number of connections and a main () that takes N from the command line, calls count (), and prints the returned value.

Explanation / Answer

int T=sc.nextInt();//integer value

int a=sc.nextInt();//first random input

int b=sc.nextInt();//second random input

if(a==b|| (a%b==0))

{connected();

}

else

{union();

}

connected()

{count();

}

int count==0;

count()

{count++;

}

union()

{for(a=0,b=0;a==b;)

{if(a%b==0)

{count++;

}

else

a++;

b++;

}

}