need some help!
Im in desperate need of help. I need to modify this code which is doing Fibonacci Numbers. I need to modify the code so that it restricts the value of the first number to a whole number greater than or equal to zero, restrict the value of the second number greater than or equal the first number, and restrict the value of the input when prompted for the element to dsiplay a whole number greater than or equal to one.
I'm really confused and need help
This is a part of the code i need to modify.
int current = 0;
inputString = JOptionPane.showInputDialog("Enter the first " + "Fibonacci number; ");
previous1 = Integer.parseInt(inputString);
inputString = JOptionPane.showInputDialog("Enter the second " + "Fibonacci number; ");
previous2 = Integer.parseInt(inputString);
outputString = "The first two number sof the " + "Fibonacci sequence are: " + previous1 + " and " + previous2;
inputString = JOptionPane.showInputDialog("Enter the position " + "of the desired number in " + "the Fibonacci sequence: ");
nthFibonacci = Integer.parseInt (inputString);
if (nthFibonacci == 1)
current = previous1;
else if (
else if (nthFibonacci == 2)
current = previous2;
counter = 3;
while (counter <= nthFibonacci)
current = previous2 + previous1;
previous1 = previous2;
previous2 = current;
outputString = outputString + "\nThe " + nthFibonacci + "th Fibonacci number of " + "the sequence is: " + current;
JOptionPane.showMessageDialog(null, outputString, "Fibonacci Number", JOptionPane.INFORMATION_MESSAGE);