Golden Sun Syndicate Forums: Golden Sun Syndicate Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Need help with Java. Loops

#1   Moonear 

  • Disciple
  • PipPipPipPipPipPipPipPip
    • Group: Veterans
    • Posts: 1,769
    • Joined: 06-October 07
    • Gender:Male
    • Location:LongGuy Land

    Posted 25 October 2008 - 05:27 PM

    I'm taking a Java class, and I need help with an assignment using loops. We're using Eclipse SDK. The point of the assignment is to take all even integers between 2 and 100 and find the sum. I started a new project and made a do-while loop, but I can't get the right formula. Could anyone please tell me the formula or say if I should use another type of loop?

    #2   Max 

    • Administrator
    • PipPipPipPipPipPipPipPip
      • Group: Admin
      • Posts: 1,837
      • Joined: 26-January 04
      • Gender:Male
      • Location:Philadelphia

      Posted 25 October 2008 - 09:01 PM

      I don't like giving people answers to their homework, so I'm just going to speak in vague terms and you'll have to figure it out yourself:

      Since you know how many loop iterations you need, I would generally not use a do-while loop, but another type. A simple check for evenness while keeping a running tally and you should be good.

      #3   Moonear 

      • Disciple
      • PipPipPipPipPipPipPipPip
        • Group: Veterans
        • Posts: 1,769
        • Joined: 06-October 07
        • Gender:Male
        • Location:LongGuy Land

        Posted 27 October 2008 - 04:15 PM

        Thanks for the help, I finally got the answer today while experimenting with for loops. I do have a problem with a lab where the goal is to find the square, cube, and square root of a number, and then put it all into a table-like format.

        EDIT: Never mind, figured it out. I needed to use EasyFormat.


        Page 1 of 1
        • You cannot start a new topic
        • You cannot reply to this topic