Results 1 to 3 of 3
  1. #1
    jarvis is offline Member
    Join Date
    Apr 2009
    Posts
    1
    Rep Power
    0

    Default strange alternating array

    Well hello java enjoyers, i am new to java but not programing all together. I know some python and c+ but not much else. I was trying to figure out away to write a program that reads a sequence of integers into an array list and computes the some of the numbers. But the computation must alternate in between + and -. For example
    Number set [4,2,5,7,6,7]
    computation 4+2-5+7-6+7=9
    output 9
    im snaning in the number set and trying to use a for loop but cant figure it out. Any suggestions?

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default

    Post the code you're using. It's a bit tough to correct it without seeing it.

  3. #3
    kbindumadhavi is offline Member
    Join Date
    Apr 2009
    Posts
    20
    Rep Power
    0

    Default

    Please be specific where you got stuck with.
    I think you are expecting some logic for using alternate computations.
    My suggestion is using '%' operator.

Similar Threads

  1. Alternating Sum
    By ScaryJello in forum New To Java
    Replies: 6
    Last Post: 10-13-2009, 09:18 AM
  2. strange code
    By tghn2b in forum New To Java
    Replies: 3
    Last Post: 12-22-2008, 11:51 PM
  3. strange Error message
    By little_polarbear in forum New To Java
    Replies: 4
    Last Post: 08-25-2008, 11:45 PM
  4. Strange problem
    By Tamir in forum Eclipse
    Replies: 1
    Last Post: 08-18-2008, 09:44 PM
  5. Strange behaviour in swing
    By cbalu in forum AWT / Swing
    Replies: 1
    Last Post: 05-23-2008, 09:23 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
  •