home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / misc / ada1110b.lha / Examples / Navy.ada < prev    next >
Encoding:
Text File  |  1992-03-07  |  1.7 KB  |  74 lines

  1. --I haven't the slightest idea what this really does, but at least
  2. --you can test some of the error handling with it.
  3.  
  4. --From schweige@taurus.cs.nps.navy.mil Sun Mar  1 21:06:35 1992
  5. --Return-Path: <schweige@taurus.cs.nps.navy.mil>
  6. --Date: Sun, 1 Mar 92 18:06:03 PST
  7. --From: schweige@taurus.cs.nps.navy.mil (Jeffrey M. Schweiger)
  8. --To: black@beno.CSS.GOV
  9. --Subject: Ada program
  10. --Status: R
  11. --
  12. --Mike -
  13. --
  14. --The following Ada program does not have any graceful error handling
  15. --built in, so improper data entry will cause it to crash.
  16. --
  17. --Jeff Schweiger
  18. with TEXT_IO;
  19. use TEXT_IO;
  20.  
  21. procedure MOE is
  22.  
  23.     type V_ARRAY is array (1 .. 5) of FLOAT;
  24.     S, M :  V_ARRAY;
  25.     ST, MT : FLOAT;
  26.  
  27.     package INT_IO is new INTEGER_IO(INTEGER);
  28.     package FLOAT_INOUT is new FLOAT_IO(FLOAT);
  29.     use INT_IO, FLOAT_INOUT;
  30.  
  31.  
  32.     procedure GET_INPUT (S, M : out V_ARRAY) is
  33.  
  34.  
  35.     begin
  36.  
  37.         for I in 1 .. 5 loop
  38.             PUT("Enter S[");
  39.             PUT(I, width => 1);
  40.             PUT("]:  ");
  41.             GET(S(I));
  42.             SKIP_LINE;
  43.             NEW_LINE;
  44.         end loop;
  45.  
  46.             NEW_LINE(2);
  47.  
  48.         for I in 1 .. 5 loop
  49.             PUT("Enter M[");
  50.             PUT(I, width => 1);
  51.             PUT("]:  ");
  52.             GET(M(I));
  53.             SKIP_LINE;
  54.             NEW_LINE;
  55.         end loop;
  56.  
  57.     end GET_INPUT;
  58.  
  59. begin
  60.  
  61.    GET_INPUT(S, M);
  62.    ST := (S(1)* 0.2) + (S(2)* 0.15) + (S(3)* 0.1) + (S(4)* 0.25) + (S(5)* 0.3);
  63.    MT := (M(1)* 0.25) + (M(2)* 0.1) + (M(3)* 0.15) + (M(4)* 0.2) + (M(5)* 0.3);
  64.    PUT("Tactical MOE is ");
  65.    PUT((ST/MT), FORE => 2, AFT =>4, EXP => 0);
  66.    NEW_LINE(2);
  67.    PUT("Normalized Tactical MOE is ");
  68.    PUT((ST/(ST + MT)), FORE => 2, AFT =>4, EXP => 0);
  69.    NEW_LINE(2);
  70.  
  71.  
  72. end MOE;
  73.  
  74.