comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Need Help..
Date: 1997/11/01
Date: 1997-11-01T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680000111971709260001@news.ni.net> (raw)
In-Reply-To: 345346AB.77C4@upnaway.com


In article <345346AB.77C4@upnaway.com>, sho@upnaway.com wrote:


>I have encountered a difficult task in programming with Ada,the task of
>this program is to get user input for an exression such as:
>(X+y)/(a+b)
>then it will check for any errors,when there is no error.The program
>should ask the user for an input to define X,y,a,b then evaluate the
>values.It might seems simple but for me it isnt:(,If any of you have
>done the same program or anything similar to that or even some bits that
>will give me a clue on how to do it.Please email me or write on the
>board.I would like to thank you for your time and consideration:)

procedure P is

   procedure Get
      (Prompt : in String;
       Value    : out Integer) is
   begin
      Main:
      loop
         Ada.Text_IO.Put ("Enter " & Prompt & ": ");

         begin
            Ada.Integer_Text_IO.Get (Value);

            exit Main;

         exception
            when Ada.Text_IO.Data_Error => 
               Ada.Text_IO.Skip_Line;
               Ada.Text_IO.Put ("Bad value; try again: ");

         end;

      end loop Main;
   end Get;

   X, Y, A, B : Integer;
begin

   Get ("X", X);
   Get ("Y", Y);
   Get ("A", A);
   Get ("B", B);

   <eval expr using X, Y, A, B>

exception
   when Ada.Text_IO.End_Error =>
      null;

end;

Will that do what you want?

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-11-01  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-26  0:00 Need Help sho
1997-11-01  0:00 ` Matthew Heaney [this message]
  -- strict thread matches above, loose matches on Subject: below --
1998-10-14  0:00 need help mostoc
1998-10-15  0:00 ` Pascal Obry
1998-01-12  0:00 Need help Scott Barrish
1998-01-11  0:00 ` Matthew Heaney
1996-11-19  0:00 Antonio Casimiro Costa
1994-11-15  1:10 need help Basri Basri
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox