0

Hey everyone, I am having trouble on this one practice problem. It is a question that requires another question I already completed to solve this one. The qusetion is "Implement a method allPerfect() that takes an integer parameter end. The method prints every perfect number from 1 to end. Use the method isPerfect() above to check if a number is perfect. " I am confused on how to use isPerfect to check if the number is perfect or not. Any help would be greatly appreciated.

This is my isPerfect code:

```
import java.util.*;
public class isPerfect
{
public boolean isPerfect(int num)
{
int count = 0;
for(int i = 1; i<= num/2 ; i++)
{
if(num%i == 0)
{
count +=i;
}
}
if(count == num)
{
System.out.println("This is a pefect number");
return true;
}
else
{
System.out.println("This is not a perfect number");
return false;
}
}
public static void main(String[]args)
{
isPerfect ip = new isPerfect();
Scanner scan = new Scanner(System.in);
System.out.println("Enter an integer value to see if it is perfect or not");
int number = scan.nextInt();
System.out.println(ip.isPerfect(number));
}
}
```