I am writing a program for a college assignment to compute grades of students. the code compiles ok, but i keep getting a runtime error 2. can anyone help?

{Author: George Brandon Miller}
{Program: Grade Report - Compute the grade point average for students}
Program Grades;

var


{ misc. program variables }

  more_records:boolean;    {end of file flag }
  line_count:integer;      {lines written count}
  page_no:integer;         {page count}
  

{Student Variables}
  FileIn:typedfile;              {Input File Handle}
  FileOut:text;                  {Output File Handle}
  SECTION_NUMBER:string[5];      {Section number of the class}
  STUDENT_ID:string[9];          {Student identification number}
  LAST_NAME:string[20];          {Students last name}
  FIRST_NAME:string[10];         {Students first name}
  RAW_SCORE:real;                {Points totaled by the student}
  STUDENT_COUNT:integer;         {total number of students}
  AVERAGE_SCORE:integer;         {Average score for all the students}
  AVERAGE_GRADE:integer;         {Grade for the student}
  PERCENT:real;
  
 procedure read_record;
  begin
   if not Eof(fileIn) then
    readln(SECTION_NUMBER,STUDENT_ID,LAST_NAME,FIRST_NAME,RAW_SCORE)
else
  more_records := False
end;  {read record}   

  procedure print_header; {print header at top of page}
 
 begin

  writeln(FileOut,space(14),'CIS150 GRADE REPORT',space(8),page_no);
  writeln(FileOut,space(17),'SECTION','SECTION_NUMBER');
  Writeln(FileOut);
  writeln(FileOut,space(9),'LAST',space(11),'FIRST','      RAW','  COMPUTED');
  writeln(FileOut,space(9),'NAME',space(11),'NAME','      SCORE','  GRADE');
  Writeln(FileOut);
  Writeln(FileOut);
  Writeln(FileOut);
  Writeln(FileOut);
  Writeln(FileOut,'STUDENT COUNT',STUDENT_COUNT);
  Writeln(FileOut,'AVERAGE SCORE',AVERAGE_SCORE);
  Writeln(FileOut,'AVERAGE GRADE',AVERAGE_GRADE);

end;

{INITIALIZE - open files and print header}

procedure initialize;

begin


  assign(fileIn,'C:\Users\Owner\Classes\CIS 150\Data\PRG3-150.DAT');
  reset(fileIn);
  assign(Fileout,'C:\Users\Owner\Classes\CIS 150\Data\grades.rpt');
  rewrite(fileout);

read_record;

print_header

end;

procedure process;

begin

   {skip to new page if needed}
Inc(line_count);
if line_count > 50 then
  Print_header;

percent := (Raw_Score / 850.0) * 100.0;
    writeln(FileOut,Last_Name,Space(2),First_Name,Space(3),percent);
    read_record;

end; 


procedure wrapup;

begin
    writeln(FileOut);
    writeln(FileOut,'Student_Count');
    Close(FileIn);
    Close(FileOut);
end; 


begin
    initialize;


    while more_records do
      process;


    wrapup

end.

Recommended Answers

All 5 Replies

I changed the filein:filetype; to fileIn:file; and now i get a runtime error 106...im completely lost...any help?

Is this a compiler error message?
Then 2:Identifier expected,106:Character expression expected

Is this a compiler error message?
Then 2:Identifier expected,106:Character expression expected

Yes it is a compiler message. and i changed the file. but im still lost.

ok,calm down a bit....now we know where the problem is,right..?...
run your program and look at the line where stops the program
and please paste that line,cause I can't run your program because of missing files...I hope that you understand what I'm talking about....

Error 2: Identifier expected.

I found this error when reading your code
procedure read_record;
begin
if not Eof(fileIn) then
readln(fileIn,SECTION_NUMBER,STUDENT_ID,LAST_NAME,FIRST_NAME,RAW_SCORE)
else
more_records := False
end;

By the way when I looking your code a bit closer I can't find any records ...why???
Create a new type 'something = record',got it?
I made a skeleton

Program Solution;


{new type for a student,it contains the data of a student}
Type Stdnt = Record
                   SECTION_NUMBER:string[5];
                       STUDENT_ID:string[9];
                        LAST_NAME:string[20];
                       FIRST_NAME:string[10];
                        RAW_SCORE:real;
                End;
Var FileIn:File of Stdnt;{declares a file that contains only records}
    OneStudent:Stdnt; {one record}


Procedure read_record;
Begin
   If Not EoF(FileIn) Then Readln(FileIn,OneStudent)
Else
   more_records := False
End;  {read record}
{
After calling this procedure,the OneStudent record is filled
with data like : just example....
OneStudent.SECTION_NUMBER := '12';
OneStudent.STUDENT_ID :='3';
OneStudent.LAST_NAME := 'Joe';
OneStudent.FIRST_NAME := 'Smith';
OneStudent.RAW_SCORE := 12.32;
and you have to work with the OneStudent record
}


Begin {main}


   ReadLn;
End.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.