Results 1 to 8 of 8
Thread: Solve my program
 12162008, 02:03 PM #1Member
 Join Date
 Dec 2008
 Location
 Davao Oriental
 Posts
 29
 Rep Power
 0
 12162008, 04:05 PM #2
couple of things
 You have posted in the wrong part of the forum. This should probably be in the "New to Java" section. The mods can move it.
 You probably already know this, but the forum won't do your assignment for you. The forum will help you to learn how to do it. To get you started, here's a way to detect if a number is odd/even:
Java Code:if (x % 2 == 0) // number is even
Java Code:if (x % 2 != 0) // number is odd
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
 01192009, 06:51 AM #3
(i%2!=0) is the condition used to do this operation
 01192009, 08:04 AM #4Senior Member
 Join Date
 Dec 2008
 Posts
 526
 Rep Power
 0
(i%2!=0) is the condition used to do this operation
 01212009, 03:09 AM #5
If you divide x by 1 It will always equal It self so there will be no remainder
Example below
Java Code:int x = 5; System.out.println(x % 1);
Java Code:int x = 5; System.out.println(x % 2);
The Modulus(%) function finds the remainder of a division .
but I would hope that you already knew that.
Hope that helps,
SariIf you don't try you can't succeed.
 01212009, 03:21 AM #6
ah... almost
Actually that's not entirely true... it prints 1, not .5. The reason being because:
 the remainder of 5/2 is not .5, it's 1
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
 01212009, 04:54 AM #7
I'm disappointed in myself messing up basic math oh well I think I got the point across
If you don't try you can't succeed.
 01212009, 07:20 AM #8
mod % means reminder
simple solution...
multiplication is related with addition,
division is related with subtraction,
modulo is the remainder...
for example,
2*5 is 10
how, 2+2+2+2+2 is 10...
similarly division
5/2 is 2 because you can subtract 2 only 2 times from 5
(1st time)52=3 (3 remainder)
(2nd time)32=1 (1 remainder)
so, 5/2 is 2 and the remainder is modulo(%)...here its 1.
understand the logic its very important...
Similar Threads

Help me to solve problem
By mansoorhacker in forum Forum GuidesReplies: 8Last Post: 01242009, 07:29 PM 
Solve my Problem
By kyo in forum New To JavaReplies: 1Last Post: 12162008, 03:22 PM 
Help me to solve problem
By mansoorhacker in forum New To JavaReplies: 3Last Post: 11132008, 09:15 AM 
how to solve capital country program in java applet
By shadab in forum AWT / SwingReplies: 2Last Post: 08272008, 03:40 PM 
Help mi solve my error
By Deon in forum New To JavaReplies: 3Last Post: 01112008, 06:26 AM
Bookmarks