programming pascal help?

Discussion in 'OT Technology' started by matt62182, May 11, 2008.

  1. matt62182

    matt62182 New Member

    Joined:
    Mar 25, 2007
    Messages:
    736
    Likes Received:
    0
    Location:
    MS
    it's taken me like 4 hours to wite this and of course there is something wrong with it that won't let it compile....and i can figure out what it could be (besides indentation). after i hit the compile button it says:

    1 illegal expression
    2 ; expected but identifier A found

    if anyone could point anything out i would be grateful, i know it's a long program


    var
    infile,outfile:text;
    score: integer;
    counter, counterA, counterB, counterC, counterD, counterF:integer;
    highest, highA, highB, highC, highD, highF:integer;
    lowest, lowA, lowB, lowC, lowD, lowF:integer;
    sum, sumA, sumB, sumC, sumD, sumF:integer;
    begin
    assign(infile,'C:/gradesfile.txt'); (*this copies and writes the data from infile to outfile*)
    assign(outfile,'grades_MattYelverton.txt');
    reset(infile);
    rewrite(outfile);
    counter A:=0; counterB:=0; counterC:=0; counterD:=0; counterF:=0;
    highA:=90; highB:=80; highC:=70; highD:=60; highF:=0;
    lowA:=100; lowB:=89; lowC:=70; lowD:=69; lowF:=59;
    sumA:=0; sumB:=0; sumC:=0; sumD:=0; sumF:=0;
    writeln(outfile, 'GradeReport':10);
    writeln(outfile,'');
    writeln(outfile,'Score','Grade');
    writeln(outfile,'_________');
    repeat (*determines the highest and lowest grade and grade score*)
    begin
    readln(infile,score);
    if score>=90 then
    begin
    writeln(outfile,'A');
    counterA:=counterA+1;
    if score >=0 then
    lowA:=score;
    sumA:=sumA+score;
    end
    else
    if score>=80 then
    begin
    writeln(outfile,'B');
    counterB:=counterB+1;
    if score >highB then
    high B:=score;
    if score lowB=score;
    sumB:=sumB+score;
    end
    else
    if score>=70 then
    begin
    writeln(outfile,'C');
    counterC:=counter C+1;
    if score >highC then
    high C:=score;
    if score lowC:=score;
    sumC:=sumC+score;
    end
    else
    if score>=60 then
    begin
    writeln(outfile,'D');
    counterD:=counterD+1;
    if score >highD then
    high D:=score;
    if score lowD:=score;
    sumD:=sumD+score;
    end
    else
    if score >=0 then
    begin
    writeln(outfile'F');
    counterF:=counterF+1;
    if score >highF then
    highF:=score;
    if score lowF:=score;
    sumF:=sumF+score;
    end;
    if score >highest then
    highest:=score;
    if (score<lowest) and (score>-1) then
    lowest:=score;
    end;
    until score=-1;
    sum:=sumA+sumB+sumC+sumD+sumF;
    counter:=counterA+counterB+counterC+counterD+counterF;
    writeln;
    writeln(outfile,' ');
    writeln(outfile,'_____');
    (*this will printout the grade report into parts*)
    writeln(outfile,'Full Test Grade Report');
    writeln(outfile, 'Out of',counter, 'students', counterA+counterB+counterC+counterD,'passes the exam.');
    writeln(outfile, 'The highest grade=',highest);
    writeln(outfile, 'The lowest grade+', lowest);
    writeln(outfile, 'The average grade=',sum div counter);
    writeln(outfile,'___________');
    (*data for grade A*)
    if counterA >0 then
    begin
    writeln(outfile, 'There is a sum of', counterA,'students who make an A.');
    writeln(outfile,'The highest A=',highA);
    writeln(outfile,'The lowest A=',lowA);
    writeln(outfile,'The average A=',sumA div counterA);
    end
    else
    writeln(outfile,'Nobody scored a grade of A on the test');
    writeln(outfile,'_________');
    (*data for grade B*)
    if counterB >0 then
    begin
    writeln(outfile,'there is a sum of',counterB,'students who make a B.');
    writeln(outfile, 'the highest B=',highB);
    writeln(outfile, 'the lowest B=',lowB);
    writeln(outfile, 'the average B=',sumB div counterB);
    end
    else
    writeln(outfile,'nobody scored a grade of B on the test');
    writeln(outfile,'__________');
    (*data for grade C*)
    if counterC >0 then
    begin
    writeln(outfile,'there is a sum of',counterC,'students whp make a C.');
    writeln(outfile,'the highest C=',highC);
    writeln(outfile,'the lowest C=',lowC);
    writeln(outfile,'the average C=',sumC div counterC);
    end
    else
    writeln(outfile,'nobody scores a grade of C on the test');
    writeln(outfile,'___________');
    (*data for grade D*)
    if counterD >0 then
    begin
    writeln(outfile,'there is a sum of',counterD, 'students whp make a D.');
    writeln(outfile,'the highest D=',highD);
    writeln(outfile, 'the lowest D=',lowD);
    writeln(outfile, 'the average D=', sumD div counterD);
    end
    else
    writeln(outfile,'nobody scored a grade of D on the test');
    writeln(outfile,'____________');

    (*data for grade F*)
    if counterF >0 then
    begin
    writeln(outfile,'there is a sum of',counterF,'students who make an F.);
    writeln(outfile,'the highest F=',highF);
    writeln(outfile,'the lowest F=',lowF);
    writeln(outfile, 'the average F=', sumF div counterF);
    end
    else
    writeln(outfile,'nobody scored a grade of F on the test');
    writeln(outfile,'________');
    close(infile);
    close(outfile);
    end.
     
  2. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    Use the code tags to preserve indentation: http://forums.offtopic.com/misc.php?do=bbcode#code

    Also you should tell us what line the problem is on as well, becaues I'm sure the compiler will too.

    There is a space between counter and A (bolded):

    Code:
    var
    infile,outfile:text;
    score: integer;
    counter, counterA, counterB, counterC, counterD, counterF:integer;
    highest, highA, highB, highC, highD, highF:integer;
    lowest, lowA, lowB, lowC, lowD, lowF:integer;
    sum, sumA, sumB, sumC, sumD, sumF:integer;
    begin
    assign(infile,'C:/gradesfile.txt'); (*this copies and writes the data from infile to outfile*)
    assign(outfile,'grades_MattYelverton.txt');
    reset(infile);
    rewrite(outfile);
    [b]counter A[/b]:=0; counterB:=0; counterC:=0; counterD:=0; counterF:=0;
    highA:=90; highB:=80; highC:=70; highD:=60; highF:=0;
    
     
  3. matt62182

    matt62182 New Member

    Joined:
    Mar 25, 2007
    Messages:
    736
    Likes Received:
    0
    Location:
    MS
    i found out what was wrong
     
  4. Doc Brown

    Doc Brown Don't make me make you my hobby

    Joined:
    Mar 31, 2006
    Messages:
    16,404
    Likes Received:
    0
    Location:
    Ohio
    You do realize that you're being a rude moron with that post, right? ^^^
     
  5. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    The least you could do is tell us what your solution was.
     

Share This Page