{
PROGRAMMED BY   : MOHAMMAD ALJADA
DOWNLOADED FROM : WWW.GEOCITIES.COM/MOHJADA
PROGRAM         : Days Program
}


USES WINCRT;

TYPE ARR=ARRAY[1..5,1..7] OF INTEGER;

VAR MAIN1:ARR;
    I,J,K:INTEGER;


PROCEDURE SHOW;
BEGIN
  GOTOXY(1,1);
  WRITELN('DAY   :  SAT  SUN  MON  TUS  WED  THR  FRI');
  WRITELN('SALES :');
  FOR I:=1 TO 5 DO
    FOR J:=1 TO 7 DO
    BEGIN
    GOTOXY(J*5+5,I+2);
    WRITE(MAIN1[I,J]);
    END;

  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('* (1) SUM OF DAY                          *');
  WRITELN('* (2) MAX OF DAY                          *');
  WRITELN('* (3) MIN OF DAY                          *');
  WRITELN('* (4) AVARAGE OF DAY                      *');
  WRITELN('* (5) SUM OF WEEK                         *');
  WRITELN('* (6) MAX OF WEEK                         *');
  WRITELN('* (7) MIN OF WEEK                         *');
  WRITELN('* (8) AVARAGE OF WEEK                     *');
  WRITELN('* (9) EXIT                                *');
  WRITELN('* SELECT NUMBER :                         *');
  WRITELN('*******************************************');

END;


PROCEDURE SUMDAY;
  VAR X1,SUM:INTEGER;
      S:STRING;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('* ENTER DAY NUMBER [1-7] :                *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  READLN(X1);
  SUM:=0;
  IF(X1<=7) AND (X1>=1) THEN
  BEGIN 
    FOR I:=1 TO 5 DO
    SUM:=SUM+MAIN1[I,X1];
    GOTOXY(3,13);
    WRITELN('SUM OF DAY ',X1,' IS ',SUM);
  END;
  GOTOXY(3,15);
  WRITELN('ENTER NEW DAY ? (Y/N)  : ');
  GOTOXY(28,15);
  READLN(S);
  IF(S='Y') OR (S='y') THEN
  SUMDAY


END;


PROCEDURE MAXDAY;
VAR X1,MAX:INTEGER;
    S:STRING;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('* ENTER DAY NUMBER [1-7] :                *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  READLN(X1);
  MAX:=MAIN1[1,X1];
  IF(X1<=7) AND (X1>=1) THEN
  BEGIN
    FOR I:=1 TO 5 DO
    IF MAIN1[I,X1]>MAX THEN MAX:=MAIN1[I,X1];
    GOTOXY(3,13);
    WRITELN('MAX OF DAY ',X1,' IS ',MAX);
  END;
  GOTOXY(3,15);
  WRITELN('ENTER NEW DAY ? (Y/N)  : ');
  GOTOXY(28,15);
  READLN(S);
  IF(S='Y') OR (S='y') THEN
  MAXDAY

END;


PROCEDURE MINDAY;
VAR X1,MIN:INTEGER;
    S:STRING;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('* ENTER DAY NUMBER [1-7] :                *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  READLN(X1);
  MIN:=MAIN1[1,X1];
  IF(X1<=7) AND (X1>=1) THEN
  BEGIN
    FOR I:=1 TO 5 DO
    IF MAIN1[I,X1]<MIN THEN MIN:=MAIN1[I,X1];
    GOTOXY(3,13);
    WRITELN('MIN OF DAY ',X1,' IS ',MIN);
  END;
  GOTOXY(3,15);
  WRITELN('ENTER NEW DAY ? (Y/N)  : ');
  GOTOXY(28,15);
  READLN(S);
  IF(S='Y') OR (S='y') THEN
  MINDAY
  

END;


PROCEDURE AVGDAY;
VAR X1:INTEGER;
    AVG:REAL;
    S:STRING;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('* ENTER DAY NUMBER [1-7] :                *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  READLN(X1);
  AVG:=0;
  IF(X1<=7) AND (X1>=1) THEN
  BEGIN
    FOR I:=1 TO 5 DO
    AVG:=AVG+MAIN1[I,X1];
    AVG:=AVG/5;
    GOTOXY(3,13);
    WRITELN('AVARAGE OF DAY ',X1,' IS ',AVG:5:2,' %');
  END;
  GOTOXY(3,15);
  WRITELN('ENTER NEW DAY ? (Y/N)  : ');
  GOTOXY(28,15);
  READLN(S);
  IF(S='Y') OR (S='y') THEN
  AVGDAY

END;


PROCEDURE SUMWEEK;
  VAR SUM:INTEGER;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  SUM:=0;
  FOR I:=1 TO 5 DO
  FOR J:=1 TO 7 DO 
  SUM:=SUM+MAIN1[I,J];
  GOTOXY(3,13);
  WRITELN('SUM OF WEEK IS ',SUM);
  GOTOXY(3,15);
  WRITELN('To Continue Press Any Key ');
  GOTOXY(28,15);
  READLN;

END;


PROCEDURE MAXWEEK;
  VAR MAX,MAXD:INTEGER;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  MAX:=MAIN1[1,1];
  MAXD:=1;
  FOR I:=1 TO 5 DO
  FOR J:=1 TO 7 DO 
  IF MAIN1[I,J] > MAX THEN
  BEGIN
  MAX:=MAIN1[I,J];
  MAXD:=J;
  END;
  GOTOXY(3,13);
  WRITELN('MAX OF WEEK IS ',MAX ,' IN DAY ',MAXD);
  GOTOXY(3,15);
  WRITELN('To Continue Press Any Key ');
  GOTOXY(28,15);
  READLN;

END;


PROCEDURE MINWEEK;
  VAR MIN,MIND:INTEGER;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  MIN:=MAIN1[1,1];
  MIND:=1;
  FOR I:=1 TO 5 DO
  FOR J:=1 TO 7 DO 
  IF MAIN1[I,J] < MIN THEN
  BEGIN
  MIN:=MAIN1[I,J];
  MIND:=J;
  END;
  GOTOXY(3,13);
  WRITELN('MIN OF WEEK IS ',MIN ,' IN DAY ',MIND);
  GOTOXY(3,15);
  WRITELN('To Continue Press Any Key ');
  GOTOXY(28,15);
  READLN;

END;


PROCEDURE AVGWEEK;
  VAR AVG:REAL;
BEGIN
  GOTOXY(1,10);

  WRITELN('*******************************************');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*                                         *');
  WRITELN('*******************************************');
  GOTOXY(28,11);
  AVG:=0;
  FOR I:=1 TO 5 DO
  FOR J:=1 TO 7 DO 
  AVG:=AVG+MAIN1[I,J];
  AVG:=AVG/(5*7);
  GOTOXY(3,13);
  WRITELN('AVARAGE OF WEEK IS ',AVG:5:2, ' %');
  GOTOXY(3,15);
  WRITELN('To Continue Press Any Key ');
  GOTOXY(28,15);
  READLN;

END;


PROCEDURE SEL;
  VAR X:INTEGER;
BEGIN
  GOTOXY(19,20);
  READLN(X);
  CASE X OF
  1:SUMDAY;
  2:MAXDAY;
  3:MINDAY;
  4:AVGDAY;
  5:SUMWEEK;
  6:MAXWEEK;
  7:MINWEEK;
  8:AVGWEEK;
  9:DoneWinCrt;
  END;
END;





{MAIN PROGRAM}

BEGIN
  CLRSCR;
  RANDOMIZE;
  FOR I:=1 TO 5 DO
    FOR J:=1 TO 7 DO
    MAIN1[I,J]:=RANDOM(100);
  K:=0;
  WHILE K<1 DO
  BEGIN 
  SHOW;
  SEL;
  END;

END.
