From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: ** X-Spam-Status: No, score=2.1 required=5.0 tests=BAYES_20,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,4a3d58309fdb60b2,start X-Google-Attributes: gid103376,public From: Kas_le_chat Subject: loop and constraint error Date: 1998/10/11 Message-ID: <3620E968.526B@attcanada.net>#1/1 X-Deja-AN: 399978579 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=iso-8859-1 MIME-Version: 1.0 Reply-To: kasino@attcanada.net NNTP-Posting-Date: Sun, 11 Oct 1998 17:13:09 GMT Newsgroups: comp.lang.ada Date: 1998-10-11T00:00:00+00:00 List-Id: I am new to ADA and I have a program to do in this langage at school. In this projet I have to get a quantity between 0 and 50.From that quantity I have to distribute it in some variables depending on a certain range.When i am out of that fiel 0..50 the program end whit constraint error, but I nead it to loop to the get variable and dont know how to do this.If you got any answers it will be welcome. Thanks. This is the code I am working whit: With text_io; use text_io; procedure pomme is package es_reels is new text_io.float_io(float); --------d�clation des constantes----------------------- c_5kg :constant float := 5.0; c_10kg:constant float := 10.0; c_20kg:constant float := 20.0; ---------d�claration des variables---------------------- v_pommes : float range 0.0..50.0; --Pour indiquer les bornes de 0 � 50 kg; v_pomme1 : float; --de o � 5 kg, n�cessaire au calcul du prix; v_pomme2 : float; --de 05 � 10 kg, n�cessaire au calcul du prix; V_pomme3 : float; --de 10 � 20 kg, n�cessaire au calcul du prix; v_pomme4 : float; --de 20 � 50 kg, n�cessaire au calcul du prix; ---------exeptions-------------------------------------- e_exeption: exception; begin text_io.put("Entrez la quantitee de pomme, MINIMUM 0 et MAXIMUM 50 Kg: "); es_reels.get(v_pommes);--Pour obtenir la quantite de pommes text_io.skip_line; if ((0.0 < v_pommes) and (v_pommes <= float(5.0))) then v_pomme1 := v_pommes; v_pomme2 := 0.0; v_pomme3 := 0.0;v_pomme4 := 0.0; elsif ((05.0 < v_pommes) and (v_pommes <= 10.0)) then v_pomme2 := v_pommes - c_5kg; v_pomme1 := 5.0; v_pomme3 := 0.0; v_pomme4 := 0.0; elsif ((10.0 < v_pommes) and (v_pommes <= 20.0)) then v_pomme3:= v_pommes - c_10kg; v_pomme2 := 5.0; v_pomme1 := 5.0; v_pomme4 := 0.0; elsif ((20.0 < v_pommes) and (v_pommes <= 50.0)) then v_pomme4 := v_pommes - c_20kg; v_pomme3 := 10.0; v_pomme2 := 5.0; V_pomme1 := 5.0; end if; exception when e_exeption => if ((v_pommes < float(0.0)) or (v_pommes > float(50.0)))then -- condition, la quantite de pomme doit etre plus grande que 0.0 et plus petite que 50. text_io.put("La quantit� de pomme n'est pas comprise entre 0 et 50 kg. ");loop end loop; end if; --------Sortie-------------------- text_io.put("pomme1= "); es_reels.put (item=>V_pomme1); text_io.skip_line; text_io.put("pomme2= "); es_reels.put (item=>V_pomme2); text_io.skip_line; text_io.put("pomme3= "); es_reels.put (item =>V_pomme3); text_io.skip_line; text_io.put("pomme4= "); es_reels.put (item =>V_pomme4); text_io.skip_line; end pomme;