Q. Complete the method “int numberOfWays(int n)” where n is the distance to cover and the method should return the number of possible combinations if a frog can jump 1 or 2 steps at a time.
|
1 2 3 4 5 6 7 8 9 10 11 12 |
public class JumpingFrog { public static int numberOfWays(int n) { throw new RuntimeException("To be completed"); } public static void main(String[] args) { System.out.println(numberOfWays(5)); } } |
The distance of…