Hi guys, maybe there is someone out there that could give a hand with the following code. I get the message "Exit code=1" and it won't compile. Also, it seems to have another problem that i can't seem to figure out. Can someone give me a hand here?

To let you see what may be the problem, I have provided the code. Big thanks for the help!

{ AUTHOR:
DATE: 3-APRIL-2011

THE FUNCTION OF THIS PROGRAM IS TO AVERAGE GRADES
AND DETERMINE WHETHER THE STUDENT HAS PASSED OR FAILED}


program StdAverage;


{DECLARATION OF VARIABLES
AmtGrade: represent the total number of grades that will be entered and works like a grade counter
grades: an array of real numbers where entered grades will be stored
enteredgrade: temporary location of a recently entered grade
StdAverage: is the grade average
StdID: is the studentís ID
StdName: represents the name of the students }

var
StdID, StdName : string;
AmtGrade : integer;
grade: array[1..10] of real;
EnterGrade, gradeCount, newgrade : integer;
gradesum, average, total: real;

{PROGRAM STARTS HERE}
begin
gradeSum:= 0.0;
gradeCount:= 0; {INITIALIZATION OF VARIABLES}
total := 0.0;
average := 0.0;

{block requests students data}
writeln('Average Calculator ');
Writeln('Enter Student ID: ');
readln(StdID);
Writeln('Enter Student Name: ');
readln(StdName);

{requests amount of grades to be entered}
writeln('Enter amount of grades to be used: ');
readln(AmtGrade);

{while loop that runs as many times needed to enter all grades required and keeps track of total}
WHILE gradeCount < AmtGrade DO
begin
gradeCount := gradeCount + 1;
writeln('EnterGrade ', StdID, ':');
readln(newgrade);
grade[gradeCount] := newgrade;
total := total + grade[gradeCount];
end;

{average is calculated here}
average := total / AmtGrade;

{PRINT STUDENTS DATA}
writeln();
writeln('Student ID: ', StdID);
writeln('Student Name: ', StdName);
writeln('StdAverage is ',average : 4 : 1);

{THIS IF CONDITION DETERMINE WHETHER STUDENT MEETS CRITERIA TO PASS AND PRINTS THE CORRECT RESULT}
if (average>=70) then
writeln('Student has Passed')
else
writeln('Student has Failed');
readln();


end.
{PROGRAM ENDS HERE}