14,696,432 members
See more:
Fibonacci numbers are integer numbers in the following integer sequence, such that every number
after the first two is the sum of the two preceding ones.
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ...
Write a Java program to get an integer number from the user, say n, and then prints the first n Fibonacci
numbers from that sequence. Also, save this sequence in an ArrayList. Then, get an integer number from
user, check to see if it is in the range of array elements and if it is valid, print the corresponding element to
that integer number.

What I have tried:

i have tried the code but it doesn't work
Posted
Updated 9-Nov-20 21:09pm
Dave Kreskowiak 27-Oct-20 16:55pm

If you don't show the code you have and describe the problem you're having, you're not going to get much help at all.

"It doesn't work" is about the most useless problem description in existence.
Rick York 27-Oct-20 17:30pm

If you need to write a Java program why have you tagged your question with C?
Patrice T 27-Oct-20 17:45pm

Gerry Schmitz 28-Oct-20 0:57am

You code you "tried" is what is referred to as vaporware.
Richard MacCutchan 28-Oct-20 4:09am

Why do you ask how to solve this in C, when the question clearly tells you to use Java? But whichever language you choose it is a relatively simple problem to solve.

## Solution 1

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]