From: Kas_le_chat <kasino@attcanada.net>
Subject: Re: loop and constraint error- I really nead help for this problem thanks
Date: 1998/10/12
Date: 1998-10-12T00:00:00+00:00 [thread overview]
Message-ID: <36216FD1.6D9D@attcanada.net> (raw)
In-Reply-To: 3620E968.526B@attcanada.net
Kas_le_chat wrote:
>
> 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;
next prev parent reply other threads:[~1998-10-12 0:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-10-11 0:00 loop and constraint error Kas_le_chat
1998-10-12 0:00 ` Frank Ecke
1998-10-12 0:00 ` loop and constraint error(Thanks that fix .....) Kas_le_chat
1998-10-13 0:00 ` Matthew Heaney
1998-10-13 0:00 ` loop and constraint error(Thanks that fix ..it all) Kas_le_chat
1998-10-12 0:00 ` Kas_le_chat [this message]
1998-10-12 0:00 ` loop and constraint error- I really nead help for this problem thanks alan walkington
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox