⚠️ Warning: This is a draft ⚠️

This means it might contain formatting issues, incorrect code, conceptual problems, or other severe issues.

If you want to help to improve and eventually enable this page, please fork RosettaGit's repository and open a merge request on GitHub.


with Ada.Text_IO;
procedure HQ9Plus is
   -- took example from bottle-task
   procedure Bottles is
      for X in reverse 1..99 loop
         Ada.Text_IO.Put_Line(Integer'Image(X) & " bottles of beer on the wall");
         Ada.Text_IO.Put_Line(Integer'Image(X) & " bottles of beer");
         Ada.Text_IO.Put_Line("Take one down, pass it around");
         Ada.Text_IO.Put_Line(Integer'Image(X - 1) & " bottles of beer on the wall");
      end loop;
   end Bottles;

   procedure Interpret_HQ9Plus (Input : in String) is
      Accumulator : Natural := 0;
      for I in Input'Range loop
         case Input (I) is
            when 'H'|'h' =>
               Ada.Text_IO.Put_Line ("Hello, World!");
            when 'Q'|'q' =>
               Ada.Text_IO.Put_Line (Input);
            when '9'     =>
            when '+'     =>
               Accumulator := Accumulator + 1;
            when others  =>
         end case;
      end loop;
   end Interpret_HQ9Plus;

   Test_Code : String := "hq9+HqQ+Qq";
   Interpret_HQ9Plus (Test_Code);
end HQ9Plus;