3 Replies - 10514 Views - Last Post: 24 October 2008 - 04:06 AM Rate Topic: -----

#1 Demilich1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-October 08

How to get java to display odd numbers

Post icon  Posted 23 October 2008 - 10:12 AM

For my class with have a homework assignment for loop where we enter two numbers then make the program display the odd numbers between to the two numbers the user input.
So i need help where someone can so me how to make java display the odd numbers between the two numbers.
I can do the rest of the assignment on my own I just need to know how to get java to display the odd numbers with using printOdd or any loop statements
Is This A Good Question/Topic? 0
  • +

Replies To: How to get java to display odd numbers

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2646
  • View blog
  • Posts: 11,167
  • Joined: 20-September 08

Re: How to get java to display odd numbers

Posted 23 October 2008 - 10:18 AM

if (number % 2 != 0) {
   // number is odd
}


Was This Post Helpful? 0
  • +
  • -

#3 Demilich1988  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-October 08

Re: How to get java to display odd numbers

Posted 23 October 2008 - 02:39 PM

View Postg00se, on 23 Oct, 2008 - 10:18 AM, said:

if (number % 2 != 0) {
   // number is odd
}


Thank you for the help
Was This Post Helpful? 0
  • +
  • -

#4 priya_lorha  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 78
  • Joined: 02-August 08

Re: How to get java to display odd numbers

Posted 24 October 2008 - 04:06 AM

if(n%2==0)
{
System.out.println("even");
}else{System.out.println("odd");

}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1