Hi im currently learning java and my teacher gave me an exercise to create a calculator wich will give you the fibonacci number you gave into the console. I already have created my fibonacci calculator but im not sure how to do a user input wich can be used as a variable. Can you help me or give me any advice ?
public class FibonacciRechner {
public static void main (String [] args){
int x = 0;
int erg1;
int erg2;
erg1 = 1;
erg2 = 2;
System.out.println(erg1);
System.out.println(erg2);
while(x < 5){
erg1 = erg2 + erg1;
System.out.println(erg1);
erg2= erg1 + erg2;
System.out.println(erg2);
x++;
}
}
}