Hi;
Here’s another Rosetta Code Task that does not work for me “out of the box”, which I think it should.
Guess the number
Guess the number - Rosetta Code
cat -n ./guess_number.adb
1 with Ada.Numerics.Discrete_Random;
2 with Ada.Text_IO;
3 procedure Guess_Number is
4 subtype Number is Integer range 1 … 10;
5 package Number_IO is new Ada.Text_IO.Integer_IO (Number);
6 package Number_RNG is new Ada.Numerics.Discrete_Random (Number);
7 Generator : Number_RNG.Generator;
8 My_Number : Number;
9 Your_Guess : Number;
10 begin
11 Number_RNG.Reset (Generator);
12 My_Number := Number_RNG.Random (Generator);
13 Ada.Text_IO.Put_Line (“Guess my number!”);
14 loop
15 Ada.Text_IO.Put ("Your guess: ");
16 Number_IO.Get (Your_Guess);
17 exit when Your_Guess = My_Number;
18 Ada.Text_IO.Put_Line (“Wrong, try again!”);
19 end loop;
20 Ada.Text_IO.Put_Line (“Well guessed!”);
21 end Guess_Number;
What is the correct solution to fix the error?
Thanks,
Retired_Build_Engineer