#1
Basically, for some weird reason my program doesn't work. Help will be appreciated.
program basura;
uses crt;
var
   ContF,CantFNC,Cont0,Cont1,Cont2,Mes,Anio,Basorg,BasorgT,Basino,BasinoT,Basrec,BasrecT,Basnorec,Casas,i,Bastotal:integer;
   Dia,FechaM,AnioS,MesS:string;
begin
     clrscr;
     writeln('Ingrese la cantidad de casas');
     readln(Casas);
     writeln('Ingrese el Dia, Mes, y A¤o con un enter entre cada dato');
     readln(Dia);
     CantFNC:=0;
     while Dia<>'***' do
           begin
           Bastotal:=0;
           BasrecT:=0;
           BasinoT:=0;
           BasorgT:=0;
           Cont0:=0;
           Cont1:=0;
           Cont2:=0;
           for i:=1 to casas do
               begin
               [B]while ((Dia<'1') or (Dia>'31')) do
                      begin
                      writeln('Dia erroneo. Ingreselo de vuelta');
                      readln(Dia);
                      end;[/B]
                readln(Mes);
               while ((Mes<1) or (Mes>12)) do
                      begin
                      writeln('Mes erroneo. Ingreselo de vuelta');
                      readln(Mes);
                      end;
               readln(Anio);
               writeln('Ingrese la cantidad de basura organica');
               readln(Basorg);
               writeln('Ingrese la cantidad de basura Inorganica');
               readln(Basino);
               writeln('Ingrese la cantidad de basura reciclable');
               readln(Basrec);
               Basnorec:=Basino-Basrec;
               Bastotal:=Bastotal+Basorg+Basino;
               BasrecT:=BasrecT+Basrec;
               BasinoT:=BasinoT+Basino;
               BasorgT:=BasorgT+Basorg;
               end;
           write('El porcentaje de basura reciclable en el ',Dia,'/',Mes,'/',Anio,' es: ',((BasrecT/Bastotal)*10):8:2,'%');
           if BasorgT>(Bastotal*0.2) then
              Cont0:=Cont0+1
              else
                  if BasrecT>(BasinoT*0.5) then
                     Cont1:=Cont1+1
                     else
                         Cont2:=Cont2+1;
           ContF:=9999;
           str(Mes, MesS);
           str(Anio, AnioS);
           if Cont2<ContF then
              begin
              FechaM:=Dia+'/'+MesS+'/'+AnioS;
              ContF:=Cont2;
              end;
           if BasorgT>Bastotal then
              CantFNC:=CantFNC+1;
           writeln('Ingrese otro dia');
           readln(Dia);
           end;
     writeln('La fecha con menor cantidad de hogares con basura contaminante de nivel 2 fue: ',FechaM);
     writeln('La cantidad de fechas donde la basura no esta contaminada es: ', CantFNC);

     readln;
end.


That. For some reason, when I enter anything that isn't something between 1 and 3, it gives me the message that it's wrong. It should be between 1 and 31, but it takes it as 1 and 3 .
Please help?

EDIT: What the program does, is check how much houses there are, and then the user enters a date, and the program checks the contamination level of the trash picked up from the houses.
The user keeps entering dates until the user enters "***" in the date.
||||||||||||||||||||
||||||||||||||||||||
||||||||||||||||||||

Last edited by urik at Apr 29, 2008,