Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 5 For this section, many methods are given. They however contain errors. Some errors are syntax error while others are logical error. The main

Question 5
For this section, many methods are given. They however contain errors. Some errors are syntax error while others are logical error. The main method contains test that will execute the two other methods and verify if they work properly.
The method is Prime checks if the number received as an argument is a prime number. A prime number is a number bigger then 1 that can only be divided by 1 or itself.
The Fibonacci method takes a number as argument and returns the value at this position in the Fibonacci series. In the Fibonacci series, each number is the sum of the two preceding position in the series. The position 0 has the value 0 and the position 1 has the value 1. This table describes the series:
\table[[],[],[],[]]
public class Q5
test getFibonacci 1(1)==1
test getFibonacci (3)=2
test )==(5
test getFibonacci (8)=21
boolean testFlag=true;
for (int 1=0;1 test.length; 1++
1f (test [1]
System.out .println ("test "+1+ "passed");
} else {
System,out.println("test "+1+" failed");
testFlag = false;
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions