Environment: eclipse
I have reached a snag with finding the perfect numbers from 0 - 1000 while using methods with multiple perimeters, one project, tow classes. There is an example on this site from quite a while ago within one single class. That is in a later chapter in my book, How to Program 8th edition and I have not learned it yet. The purpose of this exercise is to use declare and use multiple methods to find perfect numbers.
This is what i have so far:
import java.util.Scanner;
public class perfFinder {
public void doPerfNum() {
// find all the perfect numbers 1-upper range
int j=1;
boolean ans;
Scanner inp = new Scanner( System.in );
System.out.print("Enter an upper range: ");
int upperRange = inp.nextInt();
while(j<=upperRange) {
ans = isPerf(j);
if(ans)
System.out.println("Yes, it is perf "+j);
j++;
}//end while
}//end main
public boolean isPerf(int n){
if( n==6 || n==28 )
return true;
else
return false;
}// end isPerf
}//end class perfNumEx
Driver class:
import java.util.*;
public class perfNumEx {
public static void main(String[] args) {
// create an object to find perfect numbers
perfFinder findThem = new perfFinder();
//call the method to "get" the process started
findThem.doPerfNum();
}//end main
}//end class perfNumEx
This was given as an example and I must modify/recreate it to calculate the other perfect number, 496 using an algorithm. My question is what equation do I use to find it and where does it go?
Thanks in advance