Help with Java Please. Anyone good?
I am in computer science at the moment and we are supposed to do a few things for the semester "project" one of which is this
A perfect number is a positive integer such that the sum of the divisors equals the number. Thus, 28 = 1 + 2 + 4 + 7 + 14 is a perfect number. If the sum of the divisors is less than the number, it is deficient. If the sum exceeds the number, it is abundant. Write a program that takes a positive integer as input and displays a message box that indicates whether the number entered is perfect, deficient, or abundant. Your program should define the following two methods
boolean isDivisor (int number, int divisor)
int divisorSum (int number)
The method isDivisor returns true if the divisor parameter is a divisor of the number parameter, and false otherwise. The divisorSum mthod uses isDivisor to accumulate and return the sum of the proper divisors of the number parameter. Be sure to design and test the program incrementally; that is, verify that isDivisor works correctly before using it in divisorSum.
This is just one of the project I am working on at the moment. I don't really know what the difficulty level of this is, I am assuming it is pretty basic for someone who is fluent in the language. So, if anyone would be willing to give any kind of help it would be greatly appreciated.
go to planet-source-code.com for stuff like that ;)
Sweet, mkpeaches that site looks great.
+karma and thank you.
edit Haha, I just looked at that a bit more closely and there are a lot of thing s in there I still dont understand. I will try to learn some stuff off of that but most of it we havent learned yet.
2 karma dance2
That program is incredibly simple to write, and if you're a CS major it should not be a problem, even if you're new to Java. The concepts are identical no matter the language, and that program requires very little of Java language features to write.
I code Java for a living, but I'm not in the habit of doing people's homework for them (or directing them to resources where they can copy someone else's work -- shame on you mkpeaches). If you get stuck with a specific Java question, feel free to ask, but I'm not going to actually show you how to do it. ;)
Yeah, I figured it was pretty simple dmorris. I am going to try to right the code completely first and if I get stuck anywhere, I will come back here.
EDIT Oh and I am not a CS major, still in highschool. wink
oh, i didnt mean that for him to copy, i thought he would look at the code and get an idea of how it works and then be able to do it by himself.