The Artima Developer Community
Sponsored Link

Java Answers Forum
testing range

2 replies on 1 page. Most recent reply: Apr 11, 2003 8:42 AM by Matt Gerrans

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Joe

Posts: 5
Nickname: tiger19
Registered: Apr, 2003

testing range Posted: Apr 10, 2003 5:42 PM
Reply to this message Reply
Advertisement
I need to test whether numbers ranging from 2 to 100 are multiples of 2,3,4, or 5 using a "for statement". I don't need help with dialog boxes, just the correct sequence to execute the loop. Thank you.


Adam Duffy

Posts: 168
Nickname: adamduffy
Registered: Feb, 2003

Re: testing range Posted: Apr 11, 2003 2:37 AM
Reply to this message Reply
for( int i = 2; i <= 100; i++ )
{
  for( int j = 2; j <= 5; j++ )
  {
    if( ( i % j ) == 0 )
    {
      // i is a multiple of j
    }
  }
}


Adam

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: testing range Posted: Apr 11, 2003 8:42 AM
Reply to this message Reply
"i is a multiple of j" -- Shouldn't that be "am"? ;-)

Flat View: This topic has 2 replies on 1 page
Topic: Java Interface Help Previous Topic   Next Topic Topic: hashtabel help..urgent

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use