September 09, 2010, 02:05:55 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Check if number is odd or even  (Read 2853 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: February 04, 2009, 08:25:11 AM »

Here's a source file that checks each individual number if its odd or even.

Code
GeSHi (java):
  1.  
  2. /*--------------------------------------------------------------------------
  3. OddOrEven class
  4. *****************
  5. By: HappyFace http://www.engineeringserver.com
  6. Contact: info [@] engineeringserver.com
  7. Version: 04/FEB/2009
  8. "*****************
  9. Note: checks if a number is odd or even.
  10. //----------------------------------------------------------------------*/
  11.  
  12. public class OddOrEven {
  13. public static void main(String[] args){
  14. String strNumber = "4568879";
  15. for (int i = 0; i < strNumber.length(); i++){
  16. if(strNumber.charAt(i)%2 !=0){
  17. System.out.println("Odd " +  strNumber.charAt(i));
  18. }
  19. else{
  20. System.out.println("Even " +  strNumber.charAt(i));
  21. }
  22. }
  23. }
  24. }
  25.  
Created by GeSHI 1.0.7.20

Output

Even   4
Odd   5
Even   6
Even   8
Even   8
Odd   7
Odd   9
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: February 04, 2009, 08:25:11 AM »

 Logged
JVposter
Junior Member
*

Reputation: 0
Offline Offline
Posts: 1
Referrals: 0

Awards
« Reply #1 on: February 26, 2009, 05:57:26 PM »

hello!

thanks  for sharing!

Regards,
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #2 on: February 26, 2009, 06:02:09 PM »

hello!

thanks  for sharing!

Regards,

Glad you like it, if you need more help let us know.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #3 on: March 21, 2009, 09:21:22 AM »

How can I use that script?
I'm noob in java scripting, but can you allso use this script to check or a number is odd or even to bet on a number?
Like a numbergame on a site, that you have to bet on or it will be odd or even, is there a way with a (or this) script to check the number before betting:)

Thanx :)
Diedes
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #4 on: March 21, 2009, 09:25:41 AM »

How can I use that script?
I'm noob in java scripting, but can you allso use this script to check or a number is odd or even to bet on a number?
Like a numbergame on a site, that you have to bet on or it will be odd or even, is there a way with a (or this) script to check the number before betting:)

Thanx :)
Diedes

It's not javascript if you mean that but you can run it by compiling the code "Javac OddOrEven" and run it by typing "Java OddOrEven"

If you want javascript help however, take a look here: http://www.engineeringser.../forum/javascript-b134.0/
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #5 on: March 21, 2009, 02:49:50 PM »

Well ye, i actually don't know how to run Java anyway? Is it a program then?
Cuz I never went further then html and javascript So thats why i didn't reconised the diffrence:P
Anyway can you explain how the program work, and where you can use it for?
(or add me on msn:P)
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #6 on: March 21, 2009, 03:02:49 PM »

Well ye, i actually don't know how to run Java anyway? Is it a program then?
Cuz I never went further then html and javascript So thats why i didn't reconised the diffrence:P
Anyway can you explain how the program work, and where you can use it for?
(or add me on msn:P)
For tutorials about Java please take a look here: http://www.engineeringser...ips_and_tutorials-b121.0/

If you have a specific question or need help with coding an application you can post it in one of the boards. Other people can help u out like Jurka.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #7 on: March 21, 2009, 03:16:12 PM »

Well sure i want to learn it but i dont have that much time for it overall.. But I can try:P
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #8 on: March 21, 2009, 03:19:34 PM »

Well sure i want to learn it but i dont have that much time for it overall.. But I can try:P

You will like it once u get the hang of it.  isn't too hard when you spend time learning it. And like i said in my previous post, there are people here on the forums that are happy to help you out if you have any questions.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #9 on: March 21, 2009, 04:02:32 PM »

Ah but btw, i still dont get where your odd/even script is for, how to use, and what it does
Could you explain me ? Or might contact me on msn?
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #10 on: March 21, 2009, 05:31:49 PM »

Ah but btw, i still dont get where your odd/even script is for, how to use, and what it does
Could you explain me ? Or might contact me on msn?

If i did everything on msn the forum would be useless. The Javacode shows if a number is even or odd.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #11 on: March 21, 2009, 06:09:09 PM »

hehe ok, but you know omerta? (barafranca.nl) There is a sub option : Gamble district, and you can play a number game there, with odd and even:P To gamble, you know, but, can you show with this script wich number the next number will be? so you can set all your money on the right number?
Logged
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« Reply #12 on: March 21, 2009, 07:12:18 PM »

hehe ok, but you know omerta? (barafranca.nl) There is a sub option : Gamble district, and you can play a number game there, with odd and even:P To gamble, you know, but, can you show with this script wich number the next number will be? so you can set all your money on the right number?

Nope i don't, I also am pretty sure this script can't be used to see the next number. lol.
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Diedes
Member
*

Reputation: 0
Offline Offline
Posts: 14
Referrals: 0

Awards
« Reply #13 on: March 22, 2009, 02:30:42 PM »

Ohh hehe:P That was actually what I ment this script was for, but oke tobad:P
Logged
Javaforums.net :: a community about Java software development.
   

 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.297 seconds with 46 queries.

Google visited last this page September 04, 2010, 02:11:52 AM