See, I have a boolean method that gets the divisors that work by moding the number by a divisor that is checked and determined true by a for loop (not the first one, that just loops the program for a determined amount of input. I'm not sure if there's some way to take the multiple results of the loop and add them together, but that is what I need to do. right now I'm displaying the results of the loop but that was for debugging, in the end the output will be whether it is abundant (the added divisors are over the number), perfect (the added divisors equal the number) or deficient (the added divisors are less then the number) This is the code in eclipse:
import java.util.*;
public class PerfectNumber {
/**
* @param args
*/
public static void main(String[] args) {
for(int i = 0; i < 15; i++)
{
Scanner reader = new Scanner(System.in);
int number = 0;
int divisor = 1;
int addnum = 0;
System.out.println("Please input a number to check if it is perfect, abundant, or deficient");
number = reader.nextInt();
for(divisor = 1; divisor < number; divisor++)
{
isDivisor(number, divisor);
if(isDivisor(number, divisor) == true)
{
System.out.println(divisor);
}
}
}
}
static boolean isDivisor(int number, int divisor)
{
if (number % divisor == 0)
return true;
else
return false;
}
}