Data update
This commit is contained in:
parent
4d5544505c
commit
4924dd0264
3073 changed files with 55820 additions and 4408 deletions
65
Task/Biorhythms/Ada/biorhythms.ada
Normal file
65
Task/Biorhythms/Ada/biorhythms.ada
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
with Ada.Calendar;
|
||||
with Ada.Calendar.Arithmetic;
|
||||
with Ada.Calendar.Formatting;
|
||||
with Ada.Command_Line;
|
||||
with Ada.Numerics;
|
||||
with Ada.Numerics.Elementary_Functions;
|
||||
with Ada.Text_IO;
|
||||
|
||||
use Ada.Calendar;
|
||||
use Ada.Calendar.Arithmetic;
|
||||
use Ada.Calendar.Formatting;
|
||||
use Ada.Command_Line;
|
||||
use Ada.Numerics;
|
||||
use Ada.Numerics.Elementary_Functions;
|
||||
use Ada.Text_IO;
|
||||
|
||||
procedure Biorhythms is
|
||||
Birth_Date : Time := Value (Argument (1) & " 00:00:00");
|
||||
Target_Date : Time := Value (Argument (2) & " 00:00:00");
|
||||
Days : Day_Count := Target_Date - Birth_Date;
|
||||
|
||||
-- There's not much point having types for these for such a short
|
||||
-- problem, but in a big program this would be useful to prevent
|
||||
-- accidentally assigning wrong values.
|
||||
type Physical_Type is mod 23;
|
||||
type Emotional_Type is mod 28;
|
||||
type Mental_Type is mod 33;
|
||||
type Biorhythm_Type is
|
||||
record
|
||||
Physical : Physical_Type;
|
||||
Emotional : Emotional_Type;
|
||||
Mental : Mental_Type;
|
||||
end record;
|
||||
|
||||
function To_Biorhythm (D : Day_Count) return Biorhythm_Type is
|
||||
(
|
||||
Physical_Type (D mod Physical_Type'Modulus),
|
||||
Emotional_Type (D mod Emotional_Type'Modulus),
|
||||
Mental_Type (D mod Mental_Type'Modulus)
|
||||
);
|
||||
|
||||
Biorhythm : Biorhythm_Type := To_Biorhythm (Days);
|
||||
|
||||
package Float_IO is new Ada.Text_IO.Float_IO (Float);
|
||||
use Float_IO;
|
||||
|
||||
function To_Percent (F : Float) return Float is
|
||||
(100.0 * Sin (2.0 * Pi * F));
|
||||
|
||||
procedure Report_Biorhythm (B : Biorhythm_Type) is
|
||||
PFrac : Float := Float (B.Physical) / Float (Physical_Type'Modulus);
|
||||
EFrac : Float := Float (B.Emotional) / Float (Emotional_Type'Modulus);
|
||||
MFrac : Float := Float (B.Mental) / Float (Mental_Type'Modulus);
|
||||
Physical : Float := To_Percent (PFrac);
|
||||
Emotional : Float := To_Percent (EFrac);
|
||||
Mental : Float := To_Percent (MFrac);
|
||||
begin
|
||||
Put_Line ("Age in days: " & Days'Image);
|
||||
Put ("Physical cycle: "); Put (Physical, 3, 1, 0); Put ("%"); New_Line;
|
||||
Put ("Emotional cycle: "); Put (Emotional, 3, 1, 0); Put ("%"); New_Line;
|
||||
Put ("Mental cycle: "); Put (Mental, 3, 1, 0); Put ("%"); New_Line;
|
||||
end Report_Biorhythm;
|
||||
begin
|
||||
Report_Biorhythm (Biorhythm);
|
||||
end Biorhythms;
|
||||
|
|
@ -27,10 +27,10 @@ proc cycle now cyc t$ col .
|
|||
gcolor col
|
||||
gtext 4 cyc * 1.2 - 20 t$
|
||||
glinewidth 0.5
|
||||
gpenup
|
||||
for d = now - 20 to now + 20
|
||||
yp = y
|
||||
y = 50 + 20 * sin (360 * d / cyc)
|
||||
if x > 0 : gline (x - 2.5) yp x y
|
||||
glineto x y
|
||||
x += 2.5
|
||||
.
|
||||
.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue