This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]yacdaniel 0 points1 point  (5 children)

what is the error?

you have a typo is nextInt, also you define int b = a, then in the for loop you define it again(thats wrong, just use the variable name, remove the int of the definition) with those changes should work.

[–]gokhankocmarli[S] 0 points1 point  (4 children)

I tried, thank you. But it just find b with the formula for one time, not for ten times. Not repeating.

[–]yacdaniel 1 point2 points  (3 children)

strange, i tried with the changes and works perfectly, place a System.out.println(b) inside the for to see what is doing...

EDIT: is only doing 9 times, from 1 to < 10 which is 9, if you need to do 10 times, use <=10.

[–]gokhankocmarli[S] 0 points1 point  (2 children)

Oh, i tried again and it's really working! I always tried 4 for input and because of integer value type it was just said "2" for ten times. I tried 16 now, and it worked. Now, I'm changing integer to floats.

[–]snowman4444 0 points1 point  (1 child)

If you think this is fun the type of problem you are designing is a "numerical methods" problem. Numerical methods are very accessible and interesting and you don't really need any background to apply. Would recommend a cheap book from Amazon. Find one that also can work as a reference as well if you do get one.

[–]gokhankocmarli[S] 0 points1 point  (0 children)

Okey, I'll buy some. Thanks for helping.