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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started