GPL
Intended audience: all readers.
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Calculator is
Result : Integer;
Operator : Character;
begin
Put ("Enter an expression: ");
Get (Result);
loop
Get (Operator);
if Operator = '.' then
-- display result and exit from the loop
Put (Result, Width => 1);
exit;
else
-- process the rest of an operator/integer pair
end if;
end loop;
-- the call to Put has now been moved into the loop
New_Line;
end Calculator;
Ada programming, © 2005,2006 the Authors, Content is available under GNU Free Documentation License.
