Uses Crt, Dos;
Const
    TimeHon : byte = 10; TimeMon : byte = 49;
    TimeHoff : byte = 10; TimeMoff : byte = 50;
Var
    H , M, S, S1 : Word;
     SoundEnable : Boolean;
Procedure Wake;
 Var C : Word;
   B,S : Byte;
 Begin
      Randomize;
     B := Random(4)+1;
     {S := Random(30);}
     {If S=15 then B := 10;}
     If SoundEnable then
  For C := 1 to 300 do begin
                           Sound(C*10);
                           Delay(B*10);
                           If KeyPressed and (ReadKey=#27) then
                                                             begin
                                                              NoSound;
                                                              Halt(255);
                                                             end;
                         end;
 End;

procedure Analize;
Begin
 Repeat
  GetTime( H, M, S, S1 );
  GotoXY(10,1); Write ('  ',TimeHon,' : ',TimeMon,'     ');
  GotoXY(10,2); Write ('  ',TimeHoff,' : ',TimeMoff,'     ');
  GotoXY(10,3); Write ('  ',H,' : ',M,'     ');
  If (h = TimeHoff ) and (m = TimeMoff ) then SoundEnable := False;
  If (h = TimeHon ) and (m = TimeMon ) then SoundEnable := True;
  Wake;
  NoSound;
 Until KeyPressed and (ReadKey = #27);
 End;

Begin
ClrScr;
WriteLn('Enter Time On , Time Off !');
ReadLn(TimeHOn);
ReadLn(TimeMOn);
ReadLn(TimeHOff);
ReadLn(TimeMOff);
ClrScr;
WriteLn('Time On  =');
WriteLn('Time Off =');
WriteLn('Time Now =');
analize;
End.