Results 1 to 11 of 11
Thread: need some exercises
 05112011, 06:33 PM #1Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
 05112011, 07:26 PM #2
Try Project Euler
db
 05112011, 07:44 PM #3Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
Thanks for that, that's just what I've been looking for and I already solved problem 1:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Java Code:public class Problem1 { public static void main(String[] args){ int multiple1 = 3; int multiple2 = 5; int max = 1000; int sum = 0; int current = multiple1; do{ if (current%multiple1==0current%multiple2==0){ sum+=current; } current++; }while(current<max); System.out.println("The sum of all the multiples of " +multiple1+" or " +multiple2+" below "+max+" is "+sum); } }
 05112011, 07:53 PM #4How to Ask Questions the Smart Way
Static Void Games  GameDev tutorials, free Java and JavaScript hosting!
Static Void Games forum  Come say hello!
 05112011, 07:57 PM #5Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
I guess so, but it's the only one that I'm going to post. It was an easy one and I'm sure loads of people will be able to solve it without cheating. If they do cheat by looking at my source then they wont achieve anything.
I only have 336 problems left to solve, I think I'll just do one a day though.
 05112011, 08:26 PM #6
I actually made a nice little GUI to combine all my solutions when I started poking around Project Euler. It looks about as ugly as all my programs do, but you (or someone else) might be able to prettify it. Basically, you name your classes Euler<number> (so Euler001 for problem 1, Euler002 for project 2, etc) and have it extend EulerSolution. For instance, my class for the first Euler project is:
Java Code:class Euler001 extends EulerSolution { long solve() { int solution=0; // Solution goes here! return solution; } }
 05112011, 08:26 PM #7
Oh, and make sure to run it from a console, because that's where the solution is printed.
 05112011, 08:28 PM #8
 Join Date
 Jan 2011
 Location
 Richmond, Virginia
 Posts
 3,069
 Blog Entries
 3
 Rep Power
 12
Codingbat is a good website for logic, recursion, string manipulation, and other types of challenge. Most are fairly simple but it definitely gets you used to a lot of the classes/primitives and how they work.
 05112011, 08:35 PM #9Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
Thanks Toll,
I'm just figuring out how I can put this to use. If I make any improvements to it in the future, I will let you know and see.
Thanks Sunde887,
I was just going to ask if anyone knew of any sites like this that wasn't entirely dedicated to mathematical programming.
 05112011, 08:46 PM #10Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
I just tried that codingbat website and when I clicked go after writing the code, nothing happened. I was expecting it to tell me if I was right or wrong, and also I thought I would click the show solution button and still nothing happened.:(
 05112011, 08:48 PM #11Member
 Join Date
 May 2011
 Posts
 64
 Rep Power
 0
Similar Threads

OOP exercises
By sunde887 in forum New To JavaReplies: 6Last Post: 01092011, 09:05 PM 
Exercises
By amzers in forum New To JavaReplies: 6Last Post: 12122010, 10:58 AM 
A place to post beginner/inter exercises/scenarios
By helpisontheway in forum New To JavaReplies: 0Last Post: 01272010, 10:03 AM 
Some exercises
By javaamateur in forum New To JavaReplies: 7Last Post: 12022009, 01:00 AM 
Exercises
By lclclc in forum New To JavaReplies: 3Last Post: 09142009, 11:20 PM
Bookmarks