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

Based on the code below, please make a Javadocs that will describe each field an

ID: 3802762 • Letter: B

Question

Based on the code below, please make a Javadocs 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. each method, attribute, etc should have a discription underneath it and labled by number, 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

packages:
   1)scanner class : it is used to get the inputs from the comnnad prompt
       ex: import java.util.Scanner;

class:
   1)RecursiveFibonacciTimer

methods contains:
   i)main method
       1)print statement : entera positive integer
       2)using scanner class to get inout from user through command prompt
           Scanner sc = new Scanner(System.in);
       3)assignig value which is entered by the user to the variable called number
           int number = sc.nextInt();
       4)taking system current time
           long currentTime = System.currentTimeMillis();
       5)declaring variables  
               long previousTime;
               long elapsedTime= 0;  
       6)starting for loop with condition less than or equal to 5
           i)assiging current time to the previous time
               previousTime = currentTime;
           ii)print statements:
               System.out.print("The Fibonacci term at position ");
               System.out.print((number + k) + " is ");
               System.out.println(fib(number + k));

           iii)assiging current milli seconds to current time
               currentTime = System.currentTimeMillis();
           iv)assigning value to the elapsed time by doing the belowe calculation
               elapsedTime= (currentTime - previousTime) / 1000;
           v)print statement:  
               System.out.println("Computed in "+ elapsedTime + " seconds. ");

7) end of for loop and mainmethod
              
   ii)fib method:public static long fib(long n)
          

           1)taking array variable called fib[] and assign value come from the formal parameter
           long fib[] = new long[(int) (n+1)];
           2)assiging values to the aray elements
               fib[0] = 0;
                fib[1] = 1;
           3)starting for loop
                   having condition less than or equal to the formal paramter n
               i)logic :assiging value to the ith element by adding i-1 element and i-2 element
                   fib[i] = fib[i-1] + fib[i-2];
           4)retruning the value fib[(int)n)
                  

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