Advertisement
calcpage

C6X5_FibTester.java

Jan 11th, 2012
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.81 KB | None | 0 0
  1. /*
  2. FibTester.java      MrG 2012.0109
  3. purpose:    estimate the limit of fib(n)/fib(n-1) as n approaches inf
  4. required:   FibTester.java              main class
  5.         Fib.java                derived class
  6. translator: javac FibTester.java
  7. interpreter:    java FibTester first second n
  8. */
  9. public class FibTester
  10. {
  11.     public static void main(String[] args)
  12.     {
  13.         int first = Integer.parseInt(args[0]);
  14.         int second = Integer.parseInt(args[1]);
  15.         int n = Integer.parseInt(args[2]);
  16.  
  17.         Fib ross = new Fib(first,second);
  18.  
  19.         System.out.println("n" + "\tfib(n)" + "\tfib(n)/fib(n-1)");
  20.         System.out.println("1\t" + first + "\tundef");
  21.         System.out.println("2\t" + second + "\t" + (double)second/first);
  22.         for(int i = 3; i<=n; i++)
  23.         {
  24.             ross.nextFib();
  25.             System.out.print(i + "\t" + ross.getFib());
  26.             System.out.println("\t" + ross.getRatio());
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement