这是我的代码,我在第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}
一个明显的错误是语句
IF Age>= 65 THEN
年龄是一个整数数组,所以这应该是
IF Age[count] >= 65 THEN
另一个明显的错误是最后一行应该是"END"完全停止。"结束;"您目前拥有的"if age[count]"语句的"else"分支之后的"begin"块对齐。
我建议你先学习如何为一组数据运行程序,然后展开它。你会发现"writeln/readln"对位于错误的位置。