Results 1 to 3 of 3
  1. #1
    Masken2 is offline Member
    Join Date
    Feb 2011
    Posts
    5
    Rep Power
    0

    Default need to understand code

    Iterating over the numbers 1 .. 10 and write in each an iteration (cycles in the loop) the sum of the current number and all the previous figures. Eg fourth iteration is the number 1 +2 +3 +4 = 10. For the first four iterations will be printed in the console 1, 3, 6, 10. Tip: for an extra variable that you use to store the value from the previous iterations.

    What i have got is that i know tthat i have to make a program that adds the preveius numbers with the next like 1+2 = 3 ant then 1+2+3=6 and so on but i dont know were to put it so that the next number apperars in the next line

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    Sorry, but you can't just keep posting your homework questions here without showing any real effort. What have you tried? What worked, what didn't work? How didn't it work? Be specific.

    Throw together an SSCCE that demonstrates where you're stuck, and we can go from there.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Debugger is offline Member
    Join Date
    Jan 2011
    Posts
    27
    Rep Power
    0

    Default

    Read up on loops, for loop, while, do while, and decide which is best to solve your problem

Similar Threads

  1. I cant understand OOP
    By eng_hyzoom in forum New To Java
    Replies: 4
    Last Post: 11-19-2010, 04:10 PM
  2. Trying to understand
    By ladykrimson in forum New To Java
    Replies: 20
    Last Post: 10-12-2010, 11:10 PM
  3. understand the code
    By prof.deedee in forum New To Java
    Replies: 8
    Last Post: 11-11-2009, 02:43 AM
  4. help to understand the ? mark in this code
    By carolain79@hotmail.com in forum New To Java
    Replies: 2
    Last Post: 10-13-2009, 06:57 AM
  5. Trying to understand this code
    By new2java2009 in forum New To Java
    Replies: 2
    Last Post: 09-09-2009, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •