BEGIN
(*Declaration of variables*)
每次运行程序时,我都会不断收到相同的错误,表明本节中的语法有问题
parish : String; (*Error: identifier not found "parish"*)
pat_mny, sa_mny, sm_mny, se_mny, sj_mny, p_mny, st_mny : Real; (*Fatal: Syntax error, ";" expected but ":" found*)
j, sa, sm, se, sj, p, st, max : Integer;
此程序计算拜访每个教区的患者总数并显示最大教区成本
Print ('*****Ministry of Health Database File*****');
Print ('Hello, this is the Dengue Eradication Task Force Computing Program, please make sure to follow the instructions given else there will be a compile error ');
Print('ALL parishes entered MUST BE spelt correctly. Any parish from the parish list may be entered (EXCEPTIONS WILL PRODUCE A COMPILE ERROR).')
Print ('PARISH LIST: St. Ann, St. Mary, St. Thomas, St. Elizabeth, St. James and Portland');
(*Loop to ensure that the program repeats this block of code 10 times*)
(*Prompting the user for input*)
for j :=1-10 do
begin
Write ('Enter the name of the parish the patient visited: ');
Readln (parish);
Write ('Enter the amount that the patient paid:');
Readln (pat_mny);
(*Processing to compute the number of patients and the total cost for each parish*)
while (parish := "St. Ann") do
begin
sa := 1+0;
sa_mny := sa_mny+ pat_mny;
end;
while (parish := "St. Mary") do
begin
sm:=1+0;
sm_mny := sm_mny+pat_mny;
end;
while (parish := "St. Elizabeth") do
begin
se :=1+0;
se_mny := se_mny+pat_mny;
end;
while (parish := "St. Thomas") do
begin
st := 1+0;
st_mny := st_mny+pat_mny;
end;
while (parish := "St. James") do
begin
sj :=1+0;
sj_mny := sj_mny+pat_mny;
end;
while (parish := "Portland") do
begin
p:=1+0;
p_mny :=p_mny+pat_mny;
end;
end;
(*Processing to compute the maximum cost*)
max :=0;
if ( sa<sm) then
begin
max:=sm;
end;
else if (sm<se) then
begin
max:=se;
end;
else if (se<st) then
begin
max:=st;
end;
else if (st<sj) then
begin
max:=sj:
end;
else
begin
max:=p;
end;
end;
(*Prompting the computer output*)
Writeln ('St. Ann: Total cost $', sa_mny 'No. of Patients', sa)
Writeln ('St. Mary: Total cost $', sm_mny 'No. of Patients', sm)
Writeln ('St. Elizabeth: Total cost $', se_mny 'No. of Patients', se)
Writeln ('St. Thomas: Total cost $', st_mny `enter code here`'No. of Patients', st)
Writeln ('St. James: Total cost $', sj_mny 'No. of Patients', sj)
Writeln ('Portland: Total cost $', p_mny 'No. of Patients', p)
Writeln ('The maximum total cost is $', max)
Print ('Thank you for using the DETF Computing Program. Good day!')
END.
这是上面整个代码的改正...感谢所有愿意抽出宝贵时间来评论我的问题的人,谢谢您的帮助和关注。
Program DETFComputingProgram;
Var
(*Declaration of variables*)
parish : String;
pat_mny, sa_mny, sm_mny, se_mny, sj_mny, p_mny, st_mny, max: Real;
j, sa, sm, se, sj, p, st : Integer;
Begin
sa_mny:=0; sm_mny:=0; se_mny:=0; sj_mny:=0; p_mny:=0; st_mny:=0 ;
sa:=0; sm:=0; se:=0; sj:=0; p:=0; st:=0 ;
Writeln('*****Ministry of Health Database File*****');
Writeln ('Hello, this is the Dengue Eradication Task Force Computing Program, please make sure to follow the instructions given else there will be a compile error ');
Writeln('ALL parishes entered MUST BE spelt correctly. Any parish from the parish list may be entered (EXCEPTIONS WILL PRODUCE A COMPILE ERROR).');
Writeln('PARISH LIST: St. Ann, St. Mary, St. Thomas, St. Elizabeth, St. James and Portland');
(*Loop to ensure that the program repeats this block of code 10 times*)
(*Prompting the user for input*)
for j :=1 to 10 do
begin
Writeln('Enter the name of the parish the patient visited: ');
Readln (parish);
Writeln('Enter the amount that the patient paid:');
Readln (pat_mny);
(*Processing to compute the number of patients and the total cost for each parish*)
if (parish ='St. Ann') then
begin
sa := sa+1;
sa_mny := sa_mny+ pat_mny;
end;
if (parish ='St. Mary') then
begin
sm:=sm+1;
sm_mny := sm_mny+pat_mny;
end;
if (parish ='St. Elizabeth')then
begin
se :=se+1;
se_mny := se_mny+pat_mny;
end;
if (parish = 'St. Thomas') then
begin
st := st+1;
st_mny := st_mny+pat_mny;
end;
if (parish = 'St. James')then
begin
sj :=sj+1;
sj_mny := sj_mny+pat_mny;
end;
if (parish = 'Portland') then
begin
p:=p+1;
p_mny :=p_mny+pat_mny;
end;
end;
(*Processing to compute the maximum cost*)
max :=0;
if ( sa_mny<sm_mny) then
max:=sm_mny
else
if (sm_mny<se_mny) then
max:=se_mny
else
if (se_mny<st_mny) then
max:=st_mny
else
if (st_mny<sj_mny) then
max:=sj_mny
else
max:=p_mny;
end.
(*Prompting the computer output*)
Writeln ('St. Ann: Total cost $', sa_mny 'No. of Patients', sa)
Writeln ('St. Mary: Total cost $', sm_mny 'No. of Patients', sm)
Writeln ('St. Elizabeth: Total cost $', se_mny 'No. of Patients', se)
Writeln ('St. Thomas: Total cost $', st_mny 'No. of Patients', st)
Writeln ('St. James: Total cost $', sj_mny 'No. of Patients', sj)
Writeln ('Portland: Total cost $', p_mny 'No. of Patients', p)
Writeln ('The maximum total cost is $', max)
Print ('Thank you for using the DETF Computing Program. Good day!')
End.