home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / ada / tutorial / fibtest.ada < prev    next >
Text File  |  1991-03-25  |  912b  |  32 lines

  1. with TEXT_IO; use TEXT_IO;
  2. procedure FIBTEST is
  3.    PASSED : BOOLEAN := TRUE;
  4.    function FIB(N : in POSITIVE) return POSITIVE is separate;
  5.    procedure COMPARE (N : in POSITIVE; RIGHT_ANSWER : in POSITIVE) is
  6.       package INT_IO is new INTEGER_IO(INTEGER); use INT_IO;
  7.       MY_ANSWER : POSITIVE := FIB(N);
  8.    begin
  9.       if MY_ANSWER /= RIGHT_ANSWER then
  10.          PUT("N:");  PUT(N);
  11.          PUT("          My answer:");  PUT(MY_ANSWER);
  12.          PUT("          Right answer:");  PUT(RIGHT_ANSWER);
  13.          NEW_LINE;
  14.          PASSED := FALSE;
  15.       end if;
  16.    end COMPARE;
  17. begin
  18.    COMPARE(1, 1);
  19.    COMPARE(2, 1);
  20.    COMPARE(3, 2);
  21.    COMPARE(4, 3);
  22.    COMPARE(5, 5);
  23.    COMPARE(6, 8);
  24.    COMPARE(7, 13);
  25.    COMPARE(10, 55);
  26.    COMPARE(15, 610);
  27.    COMPARE(20, 6765);
  28.    if PASSED then
  29.       PUT_LINE("Congratulations, you completed the assignment!");
  30.    end if;
  31. end FIBTEST;
  32.