home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / modula2 / tutorial / programs / tempconv.mod < prev    next >
Text File  |  1993-03-14  |  1KB  |  40 lines

  1.                                        (* Chapter 4 - Program 4 *)
  2.  
  3. (* This program is a good example of proper formatting, it is   *)
  4. (* easy to read and very easy to understand.  It should be a    *)
  5. (* snap to update a program that is well written like this. You *)
  6. (* should begin to develop good formatting practice early in    *)
  7. (* your programming career.                                     *)
  8.  
  9. MODULE TempConv;
  10.  
  11. FROM InOut IMPORT WriteString, WriteInt, WriteLn;
  12.  
  13. VAR Count      : INTEGER;   (* a variable used for counting     *)
  14.     Centigrade : INTEGER;   (* the temperature in centigrade    *)
  15.     Farenheit  : INTEGER;   (* the temperature in farenheit     *)
  16.  
  17. BEGIN
  18.  
  19.    WriteString("Farenheit to Centigrade temperature table");
  20.    WriteLn;
  21.    WriteLn;
  22.  
  23.    FOR Count := -2 TO 12 DO
  24.       Centigrade := 10 * Count;
  25.       Farenheit := 32 + Centigrade *9 DIV 5;
  26.       WriteString("   C =");
  27.       WriteInt(Centigrade,5);
  28.       WriteString("     F =");
  29.       WriteInt(Farenheit,5);
  30.       IF Centigrade = 0 THEN
  31.          WriteString("   Freezing point of water");
  32.       END;
  33.       IF Centigrade = 100 THEN
  34.          WriteString("   Boiling point of water");
  35.       END;
  36.       WriteLn;
  37.    END; (* of main loop *)
  38.  
  39. END TempConv.
  40.