For Java IO we will start with a pretty basic Scanner project that reads in a number n and gives you the nth number of the Fibonacci sequence. The code is listed below:

fibonacci.java

import java.util.*;
public class fibonacci{
  public static long fib(final int n)
  {
   return (n < 2) ? n : fib(n - 1) + fib(n - 2);
  }
  public static void main (String[] args){
    Scanner s = new Scanner(System.in);
    int nth = s.nextInt();
    long fibnum = fib(nth);
    System.out.println(fibnum);
  }
}

As you can see above, this Java file creates a scanner at the standard in and reads in an integer. It takes this integer and runs it through a recursive method named "fib" to generate the nth number of the Fibonacci sequence.

Now that we have created our perfect code fibonacci.java file, we will zip it up and submit it as part of a new project.

After creating the Fibonacci project with the perfect code file, we can enter the test case manager to add tests for the students.

For the first few test cases, let's cover the first few parts of the sequence.

The modern sequence goes 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...
Test cases would be input like this for the first 3 numbers in the sequence:

Test 0
Input:
0
Expected Output:
0

Test 1
Input:
1
Expected Output:
1

Test 2
Input:
2
Expected Output:
1

...

Test 20
Input:
20
Expected Output:
6765

Test 40
Input:
40
Expected Output:
102334155

So on and so forth. You don't have to add just these numbers - you can add random numbers or ones that are much larger. You can add as many test cases as you'd like.

Did this answer your question?