albert abbene

Greenhorn
+ Follow
since Jun 22, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by albert abbene

Hello. My program is supposed to accept #test cases. For each test case, it must accept two integers as a range, then return all prime numbers within the range.
Currently, it prints odd numbers within the range.
So I suspect my problem is within the Boolean i'm using to test whether a number is prime or not.
I pulled the code for the Boolean from this site - http://www.mkyong.com/java/how-to-determine-a-prime-number-in-java/
Maybe I didn't quite understand it, or maybe that's not my real issue.
Any help would be greatly appreciated. Please, and thank you!
11 years ago
I restarted from scratch, and was able to write the program to emulate the behavior I desired. It accepts 2 numbers to be input from a user, then scans the range of integers for Perfect Numbers and prints them.



I ran into all sorts of problems attempting to split this behavior into separate methods, where variables couldn't be resolved to types, or could not be passed between static/public methods. etc. Your comments have been extremely helpful. Thank you.
11 years ago

Greg Brannon wrote:Eclipse isn't giving you the run option you're used to, because Eclipse doesn't recognize the code as a runnable Java class. Why? Because the signature of your main() method is not correct. Can you fix it?



I went ahead and fixed the header, at which point my variables in the main() method were flagged with something like:

Cannot make a static reference to the non-static method getRange() from the type Pnum

Also, after fixing the main() method signature, eclipse is still not recognizing the code as a runnable Java class. Why? I don't know, maybe I havn't actually fixed it

At least i figured out how the code tags work, makes it so much more readable.


11 years ago
Hello, I am having some trouble getting this code to compile and run within eclipse. The problem is when i click to "Run" the program, it brings me to the "Type to Run" window, but my program is not on this list.
Everything I have written previously has always appeared on this list as a "type to run." I think I am overlooking something basic because I am still VERY new to programming.

Thank you very much in advance. Also, my apologies for the format. I tried putting <code> tags around it, but they did nothing.




(I put in the code tags for you. You just guessed wrong about the tag format. Next time you post, click the "Code" button and see what you get. -- Paul C)


11 years ago