-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadademo2.adb
More file actions
86 lines (76 loc) · 2.4 KB
/
adademo2.adb
File metadata and controls
86 lines (76 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
with Ada.Text_IO;
--use Ada.Text_IO;
with Ada.Numerics.Elementary_Functions;
with Ada.Float_Text_IO;
procedure adaDemo2 is
type Day_type is range 1 .. 31;
type Month_type is range 1 .. 12;
type Year_type is range 1800 .. 2100;
type Hours is mod 24;
type Weekday is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
type Date is
record
Day : Day_type;
Month : Month_type;
Year : Year_type;
end record;
type Cog is new Integer;
type rearGears is array(Cog) of Cog ;
subtype Working_Hours is Hours range 0 .. 12; -- at most 12 Hours to work a day
subtype Working_Day is Weekday range Monday .. Friday; -- Days to work
fl1 : float;
g : float;
begin
fl1 := 2.0;
-- rearGears := (12,14,16,18,22,26,40);
--Work_Load: constant array(Working_Day) of Working_Hours -- implicit type declaration
-- := (Friday => 6, Monday => 4, others => 10); -- lookup table for working hours with initialization
-- while a is not equal to b, loop.
--while a /= b loop
-- Ada.Text_IO.Put_Line ("Waiting");
--end loop;
--if a > b then
-- Ada.Text_IO.Put_Line ("Condition met");
--else
-- Ada.Text_IO.Put_Line ("Condition not met");
--end if;
-- g := Ada.Numerics.Generic_Complex_Elementary_Functions.Sqrt(fl1);
for i in 2..10 loop
g := Ada.Numerics.Elementary_Functions.Sqrt ( float(i) );
Ada.Float_Text_IO.Put(g,5,4,0);
Ada.Text_IO.Put_Line("");
end loop;
-- 1.414
--Iteration:
--for f in range
for i in 1 .. 10 loop
Ada.Text_IO.Put ("Iteration: ");
--Ada.Text_IO.Put (i);
Ada.Text_IO.Put_Line("");
end loop;
--loop
-- a := a + 1;
-- exit when a = 10;
-- end loop;
for i in 0..5 loop
case i is
when 0 => Ada.Text_IO.Put ("zero");
when 1 => Ada.Text_IO.Put ("one");
when 2 => Ada.Text_IO.Put ("two");
-- case statements have to cover all possible cases:
when others => Ada.Text_IO.Put ("none of the above");
Ada.Text_IO.Put (" _ ");
end case;
Ada.Text_IO.Put (" x ");
end loop;
--for aWeekday in Weekday'Range loop -- loop over an enumeration
-- Put_Line ( Weekday'Image(aWeekday) ); -- output string representation of an enumeration
-- if aWeekday in Working_Day then -- check of a subtype of an enumeration
-- Put_Line ( " to work for " &
-- Working_Hours'Image (Work_Load(aWeekday)) ); -- access into a lookup table
-- end if;
--
--
--
--end loop;
end adaDemo2;