Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Based on the code bellow, could someone please make a Javadoc that will describe

ID: 3802583 • Letter: B

Question

Based on the code bellow, could someone please make a Javadoc that will describe each field and method of a class, its diffrent from pseudo code, it should be a list that's written into a word document, not comments in the code

import java.util.Scanner;

public class RecursiveFibonacciTimer

{

public static void main (String [] arg)

{

System.out.print("Enter a positive integer: ");

Scanner sc = new Scanner(System.in);

int number = sc.nextInt();

  

long currentTime = System.currentTimeMillis();

long previousTime;

long elapsedTime= 0;

  

for (int k = 0; k <= 5; k++)

{

previousTime = currentTime;

System.out.print("The Fibonacci term at position ");

System.out.print((number + k) + " is ");

  

System.out.println(fib(number + k));

  

currentTime = System.currentTimeMillis();

  

elapsedTime= (currentTime - previousTime) / 1000;

System.out.println("Computed in "+ elapsedTime + " seconds. ");

  

}

}

public static long fib(long n)

{

   long fib[] = new long[(int) (n+1)];

   fib[0] = 0;

   fib[1] = 1;

for(int i=2;i<=(int)n;++i){

   fib[i] = fib[i-1] + fib[i-2];

}

   return fib[(int)n];

}

  

}

Explanation / Answer

Hi, I have added Javadoc comment in code.

Please let me know in case of any issue.

import java.util.Scanner;

/**

* @author pravesh

*

*/

public class RecursiveFibonacciTimer

{

   public static void main (String [] arg)

   {

       System.out.print("Enter a positive integer: ");

       /*

       * declaring Scanner Object to get input from console

       */

       Scanner sc = new Scanner(System.in);

      

       /*

       * getting an integer input from console

       */

       int number = sc.nextInt();

       /*

       * recording current time in milliseconds

       */

       long currentTime = System.currentTimeMillis();

      

       /*

       * declaring two long type variables

       */

       long previousTime;

       long elapsedTime= 0;

       /*

       * running for loop 5 times

       */

       for (int k = 0; k <= 5; k++)

       {

          

           previousTime = currentTime;

           System.out.print("The Fibonacci term at position ");

           System.out.print((number + k) + " is ");

          

           /*

           * calling fib function with parameter number+k

           */

           System.out.println(fib(number + k));

           /*

           * recording current time in milliseconds

           */

           currentTime = System.currentTimeMillis();

           /*

           * finding the elapsed time to calculate fib(number+k)

           */

           elapsedTime= (currentTime - previousTime) / 1000;

           System.out.println("Computed in "+ elapsedTime + " seconds. ");

       }

   }

  

   /**

   * @param n

   * @return nth fibonacci number

   */

   public static long fib(long n)

   {

       /*

       * declaring a long array of size (n+1) to store fibonacci numbers

       */

       long fib[] = new long[(int) (n+1)];

      

       /*

       * storing first and second terms of fibonacci series

       */

       fib[0] = 0;

       fib[1] = 1;

      

       /*

       * calculating other fibonacci series numbers

       */

       for(int i=2;i<=(int)n;++i){

           fib[i] = fib[i-1] + fib[i-2];

       }

       return fib[(int)n]; // returning nth fibonacci number

   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote