Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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