It looks like you are using an ad blocker. That's okay. Who doesn't? But without advertising revenue, we can't keep making this site awesome. Click the link below for instructions on disabling adblock.
Welcome to the Newschoolers forums! You may read the forums as a guest, however you must be a registered member to post.
Register to become a member today!
really? Why the hell would I wanna code your entire program? Including the gui which would just be annoying to code.
But since im nice I'll give you a hint on the prime number algorithm. Use a for loop and test if x(inputed number) mod y(incrementing number above 1 and below x) = 0. If it does break the loop, the number is prime.
Now do your own homework.
You could have google'd this.... but here is a simple implementation
(sorry its not line spaced)
public static boolean isPrime(long n) { boolean prime = true; for (long i = 3; i <= Math.sqrt(n); i += 2) if (n % i == 0) { prime = false; break; } if (( n%2 !=0 && prime && n > 2) || n == 2) { return true; } else { return false; } }
and as for gui... don't do it by hand get netbeans or something to build the gui for you... will save you a ton of time and it wont be messed up. Accessing the components like text boxes and buttons shouldn't be to hard for a beginner.
fuck that man I stopped with java about 3-4 years ago... at my company we do everything in C/C++ and all interfaces are C#... I dont work with java cuz its sooooooo slowwwww
better yet, just do it in assembly and use a binary search in a look up table... prolly only take you a few thousand CPU cycles for a 32 bit unsigned int and then... well that would take like half a millisecond.