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

I\'m looking for help on Part 2 (Extra Credit) of this question. I have attached

ID: 3653526 • Letter: I

Question

I'm looking for help on Part 2 (Extra Credit) of this question. I have attached the completed code and question.


Part I answered code:

import java.util.*;

public class calculate
{
static int sum_divisors(int n)
{
int sum=0;
for(int i=1;i<=n;i++)
{
if(n%i==0) sum+=i;
}
return sum;
}
public static void main(String args[])
{
Scanner s = new Scanner(System.in);
System.out.print("Enter the value for N: ");
int N=s.nextInt();
System.out.println("N Abundand Deficient Perfect Prime");
int ca=0;
int cd=1;
int cp=0;
int cpr=0;
System.out.println("1 0 1 0 0 ");
for(int i=2;i<=N;i++)
{
int sd=sum_divisors(i);
if(sd>2*i) ca++;
if(sd<2*i) cd++;
if(sd==2*i) cp++;
if(sd==(1+i)) cpr++;
System.out.println(Integer.toString(i)+" "+Integer.toString(ca)+" "+Integer.toString(cd)+" "+Integer.toString(cp)+" "+Integer.toString(cpr));
}
}
}

Explanation / Answer

import java.util.*; public class calculate { static int sum_divisors(int n) { int sum=0; for(int i=1;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote