Question: Javascript Problem. Trying to modify existing fibonacci code in order to use a class Int couple as a return value instead of an array? Here

Javascript Problem. Trying to modify existing fibonacci code in order to use a class Int couple as a return value instead of an array? Here is the code I have with an arbitrary value put in (40), and the code for IntCouple class: public class FibonacciProg { public static int fibonacci(int numberA){ if (numberA == 0){ return 0; } else{ int fib2Array[] = fib2(numberA); return fib2Array[0]; } } public static int[] fib2(int numberA){ if (numberA == 1 || numberA == 2){ return new IntCouple(1, 1); } else{ int[] Q = fib2(numberA-1); int f1 = Q[0]; int f2 = Q[1]; return new IntCouple(f1+f2, f1); } } public static void main(String[] args) { System.out.print("Fibonacci"+fibonacci(40); } System.out.println(); } } 

Separate.java prog IntCouple

public class IntCouple {

public static int one; public static int two;

}

I'm getting two errors I don't know how to interperate? They are:

Fibonacci.java:69: error: constructor IntCouple in class IntCouple cannot be applied to given types;

return new IntCouple(1, 1);

^

required: no arguments

found: int,int

reason: actual and formal argument lists differ in length

Fibonacci.java:75: error: constructor IntCouple in class IntCouple cannot be applied to given types;

return new IntCouple(f1+f2, f1);

^

required: no arguments

found: int,int

reason: actual and formal argument lists differ in length

Any help highly appreciated, Thank you!!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!