Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 970e076

Browse files
committed
random # generator
1 parent 921ac18 commit 970e076

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

learn.adb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
with Ada.Text_IO; use Ada.Text_IO;
22
with Ada.Characters.Latin_1;
3+
with Ada.Numerics;
4+
with Ada.Float_text_IO;
5+
with Ada.Numerics.Float_Random;
36
procedure Learn is
47

58
subtype Alphabet is Character range 'A' .. 'Z';
6-
9+
Random_Value : Float; My_Generator : Ada.Numerics.Float_Random.Generator;
710
begin
8-
11+
-- Random_Value := 150.0;
912
Put_Line ("Learning Ada from " & Alphabet'First & " to " & Alphabet'Last);
1013
Ada.Text_IO.Put (Item => Ada.Characters.Latin_1.Copyright_Sign);
1114

15+
-- Initialize the generator from the system clock
16+
Ada.Numerics.Float_Random.Reset (My_Generator);
17+
for I in 1..800 loop
18+
-- Get a random float between 0.0 and 1.0
19+
Random_Value := Ada.Numerics.Float_Random.Random (My_Generator); -- Scale the float to between 100.0 and 250.0
20+
Random_Value := 150.0 * Random_Value + 100.0;
21+
Ada.Float_Text_IO.Put (Random_Value);
22+
end loop;
1223
end Learn;
1324

0 commit comments

Comments
 (0)