0 votes
in Computers & Internet by

I have a variable made by input from my main class file called upperLimit. I have an external class file in which I would like to use the variable created by the input for upperLimit, but I have forgotten how to go about it. The objective of the program is to output all perfect numbers from 1-upperLimit.

This is my main class:

import java.util.Scanner;

public class Lab13aab

{

public static void main(String args[])

{

System.out.print("In the range of [1-10000] what will the upper limit be for analysis? ===> ");

Scanner input = new Scanner(System.in);

int upperLimit = input.nextInt();

System.out.println();

checkToSee isItPerfect = new checkToSee();

int numToCheck;

for(numToCheck=1; numToCheck>=upperLimit; numToCheck++)

{

isItPerfect.analyze();

}

}

}

and this is my external class which checks to see if an individual number is a perfect number or not:

public class checkToSee

{

public void analyze()

{

int total=1;

int factor;

for(factor=2;factor<upperLimit;factor++)

{

if(upperLimit%factor==0)

{

total = total + factor;

}

}

if(total==upperLimit)

{

System.out.println(upperLimit + " is a perfect number!");

System.out.println();

}

}

}

Update:

Sweet that almost has it mark, but it isn't outputting anything. I am trying to figure out why, and if ya know could ya say?

1189 Answers

0 votes
by
Propecia Worked For Men
0 votes
by
Keflex Cause Yeast
0 votes
by
0 votes
by
<a href=https://buystromectolon.com/>ivermectin for dogs dosage</a>
0 votes
by
0 votes
by
0 votes
by
0 votes
by
Site Pour Achat Cialis
0 votes
by
0 votes
by
Welcome to zKusimused Q&A, where you can ask questions and receive answers from other members of the community.
...