aspose file tools*
The moose likes Beginning Java and the fly likes multiples project no output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "multiples project no output" Watch "multiples project no output" New topic
Author

multiples project no output

Tim Hoang
Greenhorn

Joined: Feb 24, 2011
Posts: 26
I just made this to get the final answer for this question. "Find the sum of all the multiples of 3 or 5 below 10000." I haven't got no errors on my code, but I also did not get an answer out of my code. What could be the problem?


Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi Tim, When these line of code execute

then value of f and t becomes 2000 and 3333 respectively. so it will not enter into if condition and else condition execute.


Life is easy because we write the source code.....
Tim Hoang
Greenhorn

Joined: Feb 24, 2011
Posts: 26
I was just declaring that variable to equal to the max multiple (2000 and 3333), but how come it doesn't go through the if else statement? What should I change then without messing up the rest?
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Tim Hoang wrote:how come it doesn't go through the if else statement?


Print some statement in else block then you will know that it is executing the else block.

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

In if condition you had written that

it means when f and t both are zero then only it execute if condition but here value of f and t are 2000 and 3333 respectively. so it is executing else statement.
Tim Hoang
Greenhorn

Joined: Feb 24, 2011
Posts: 26
oh i knew what happened(i wanted it to be true), what i forgot was for it to loop back in making it true. I added while loop but it doesn't work?

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Try like this:

Tim Hoang
Greenhorn

Joined: Feb 24, 2011
Posts: 26
Dam your good, nice and simple, i will rework around my code. thanks for giving me an example on using % usefully.
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Tim Hoang wrote:thanks for giving me an example on using % usefully.


Glad to hear it helps you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiples project no output