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
0 votes
by
<a href="http://cialisbay.com/">brand cialis 20mg</a> <a href="http://tadalafil.men/">tadalafil 20mg india</a> <a href="http://sildenafilapill.com/">sildenafil mexico</a> <a href="http://ivermectin.loan/">buy ivermectin pills</a> <a href="http://ivermectin.cat/">stromectol order</a>
0 votes
by
0 votes
by
0 votes
by
0 votes
by
<a href="http://allopurinolbuy.online/">can i buy allopurinol in uk</a> <a href="http://cleocinbuy.online/">cleocin for sinus infection</a> <a href="http://vardenafil.click/">vardenafil 20mg tab</a> <a href="http://sildenafil.digital/">sildenafil canada price</a> <a href="http://tadalafil.boutique/">cheapest price for tadalafil</a> <a href="http://prozac.click/">prozac tablet</a> <a href="http://indocin.online/">buy indocin online</a> <a href="http://tadalafilzrem.com/">tadalafil cheapest price</a> <a href="http://sildenafilcitrate.monster/">sildenafil generic 50 mg</a> <a href="http://dipyridamole.monster/">dipyridamole 100mg</a>
0 votes
by
<a href="http://sildenafilorder.com/">sildenafil 100mg tablets canada</a>
0 votes
by
<a href="https://tadalafilpoint.com/">cost of tadalafil generic</a>
0 votes
by
Welcome to zKusimused Q&A, where you can ask questions and receive answers from other members of the community.
...