// Name: Lab14c.java // Date: April 30, 2014 // Author: Mr. Cargill // Purpose: Driver class for Lab14c - Fibonacci package fibonacci; import java.util.Scanner; public class Lab14c { public static void main(String args[]) { int ln = 0; // The length of the sequence int fn = 0; // The fibo number the user wishes to view // Create the Scanner object used for user input. Scanner kb = new Scanner(System.in); // Prompt the user to enter the length of the sequence. System.out.print("Enter a number for the length of the Fibonacci sequence: "); while((ln=kb.nextInt()) <= 0) System.out.print("Please enter a positive integer: "); System.out.println(); // Skip a line for aesthetics // Create the Fibonacci sequence Fibonacci fb = new Fibonacci(ln); // Prompt the user to enter the element number they wish to view while(true) { System.out.print("Enter the fibo number you wish to view or -1 to exit: "); fn = kb.nextInt(); if(fn == -1) break; System.out.printf("Fibo number %d is %d.\n\n",fn,fb.getFibo(fn)); } } }