Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

java summing


  • Please log in to reply

#1
pinky707

pinky707

    New Member

  • Member
  • Pip
  • 1 posts
Hi all sorry if i have writen this in the wrong place only i dont have a clue how to use the forum :tazz:
I have to write a program using a for loop adding numbers toether like 1 to 10 or 1 to 20 even 1 to 10,000 struggling a bit with it can any one help!
vicki
  • 0

Advertisements


#2
Vaillant

Vaillant

    Member

  • Member
  • PipPipPip
  • 495 posts
Yeah I'm mildly versed in Java... Learned it over the past few months.

Sounds to me like you need a FOR loop

example

for ( int x=0; x<=10; x++)
{
newNumber = number1 + number2;
}

see, THIS loop will do the following.
initializes the variable x, at value 0, for the looping
while x is smaller or equal to 10, increment ( add 1 to x )
inside the brackets, a very simple equasion, adding number1 to number 2, giving the variable newNumber that value.

if you've got a specific problem, post some of your code. This is all i can do for now.

Hope it helps.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP