我的代码中有一些非法表达,但我不知道如何解决它

时间:2015-02-17 18:58:18

标签: syntax-error pascal

这是我的代码,我在第39 / 45,40 / 50,51 / 45,52 / 36行有非法表达并且致命:第64行的文件意外结束如果有人教你的话会非常有帮助关于pascal的一些事情。

Program PatientRecords;
{Aurthor: Vincent Lopez,
February 16,2015,
Program will read names, age and treatment cost for at least ten patients}

Var {declaration of variables}

   Name: array [1..11] of string;
   Age: array [1..11] of integer;
   T_Cost: array [1..11] of real;
   G_Cost: array [1..11] of real;
   P_Cost: array [1..11] of real;
   Count: integer;

Begin {The program starts here}

  {Initialization of variables}

  For count := 1 to 10 DO
  WriteLn('Welcome to Ministry of Health Cost of Health Care');

  WriteLn('Enter the name of the patient');

  Readln(name[count]);

  Writeln('Enter the age of the patient');

  Readln(Age[count]);

  Writeln('Enter the treatment cost for patient');

  Readln(T_cost[count]);

  IF Age>= 65 THEN

  Begin

    G_cost[count]=T_cost[count]*(100/80);
    P_cost[count]=T_cost[count]-G_cost[count];

    Writeln('Government will pay = $',G_cost[count]);
    Writeln('The patient will pay = $',P_cost[count]);

  end

  ELSE

  Begin

    G_cost[count]=T_cost[count]*(100/50);
    P_cost=T_cost-G_cost[count];

    Writeln('Government will pay = $',G_cost[count]);
    Writeln('The patient will pay = $',P_cost[count]);

    Readln;

    Writeln('Press enter to continue');

    Readln;

  END; {The program ends here}

1 个答案:

答案 0 :(得分:0)

一个明显的错误是声明

 IF Age>= 65 THEN

年龄是一个整数数组,所以这可能是

 IF Age[count] >= 65 THEN

另一个明显的错误是最后一行应该是'END'。一个句号。结束;'您目前所拥有的内容与'if age [count]'语句的'else'分支后面的'begin'块对齐。

我建议您首先学习如何为一组数据运行程序,然后展开它。您会发现'writeln / readln'对位于错误的位置。