comp.lang.ada
 help / color / mirror / Atom feed
From: N J Chackowsky <chackowsky@brandonsd.mb.ca>
Subject: Re: School Assignment--Can this be simplified?
Date: Thu, 31 Aug 2000 19:19:55 GMT
Date: 2000-08-31T19:19:55+00:00	[thread overview]
Message-ID: <39AEB8A4.82E8F3D0@brandonsd.mb.ca> (raw)
In-Reply-To: 39AEAE34.4E9753C8@brandonsd.mb.ca

And here's the revised version. Interesting that there is no pow()
function defined in elementary_functions at all. Where should I look for
standard numerical constants such as e, pi, etc.?

NJC.

-----------------------------------------------------------------------
--| Calculates and displays the relative humidity based on 
--| the temperature and dew point.
--|
--| Author: N J Chackowsky, Brandon School Division No. 40
--| Last modified: 2000 08 31
-----------------------------------------------------------------------

   with ada.text_io;
   with ada.integer_text_io;
   with ada.float_text_io;
   with ada.numerics.elementary_functions; 

   procedure humidity is
      km : constant float := 5438.0;  -- magic multiplier
      c2k : constant float := 273.15;  -- Celcius -> Kelvin conversion
term

      tempc, tempk : float;   	-- temperature in C and K
      dewc, dewk : float;	-- dew point in C and K
      rh : float;		-- relative humidity
   
   begin -- humidity
   
   	-- Get the temperature and dew point
      ada.text_io.put(item => "What is the temperature in degrees
Celcius? ");
      ada.float_text_io.get(item => tempc);
      ada.text_io.put(item => "What is the dew point in degrees Celcius?
");
      ada.float_text_io.get(item => dewc);
   
   	-- Convert from C to K
      tempk := tempc + c2k;		--probably revise this with a function call
      dewk := dewc + c2k;			--in the next lesson.
   
      rh := ada.numerics.elementary_functions.
		exp(km * (1.0/tempk - 1.0/dewk)) * 100.0;

   	-- Display results
      ada.text_io.put(item => "The relative humidity is ");
      ada.float_text_io.put(item => rh, fore => 1, aft => 1, exp => 0);
      ada.text_io.put(item => "%");
   
   end humidity;



  reply	other threads:[~2000-08-31 19:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-30  0:00 School Assignment--Can this be simplified? N J Chackowsky
2000-08-30  0:00 ` Pascal Obry
2000-08-30  0:00 ` Keith Thompson
2000-08-30  0:00 ` tmoran
2000-08-31  0:00 ` Martin Dowie
2000-08-31 11:31   ` Simon Wright
2000-08-31 11:51     ` Martin Dowie
2000-08-31 18:35   ` N J Chackowsky
2000-08-31 19:19     ` N J Chackowsky [this message]
2000-08-31 19:33       ` Pascal Obry
2000-08-31 23:03         ` Nick J Chackowsky
2000-09-01  1:02         ` tmoran
2000-09-01  4:14           ` Robert Dewar
2000-09-01 17:51             ` tmoran
2000-09-02  3:12               ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox