Hey Im new to JAVA programming i have alot of experience in C/C++ but not java was just wondering want i am doing wrong in this code. I have to take a input from the user( a number input) and then display the fibonacci series that goes with that number.
Any help would be greatly appreciated. Thanks
Here is my code
import java.util.Scanner; public class fibonacci { public static void main(String args[]){ Scanner num = new Scanner(System.in); System.out.println(num.nextLine()); System.out.println(" Fibonacci Series "); int f1, f2=0, f3=1; for(int i=1;i<=num;i++){ System.out.print(" "+f3+" "); f1 = f2; f2 = f3; f3 = f1 + f2; } } }
I get this error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The operator <= is undefined for the argument type(s) int, Scanner
at fibonacci.main(fibonacci.java:14)