非法表达式的 Pascal(新错误)
Illegal Expression's Pascal (New Errors)
Program PaidUp;
const
size=30;
var
payment,totm1,totm2,totm3:real;
section1,section2,section3,i,j,idnum:integer;
IDNUMARR:array[1..999] of integer;
PAYMENTARR:array[1..size] of real;
Procedure InitialiseVariables;
{This procedure initialises all variables used in the program}
Begin
idnum:=0;
payment:=0;
totm1:=0;
totm2:=0;
totm3:=0;
section1:=0;
section2:=0;
section3:=0;
i:=0;
j:=0;
End; {Initialise Variables}
Procedure DeclareandInitialiseArrays;
{This procedure declares and initialises all arrays used in the program}
Begin
For i:=1 to size do
begin
IDNUMARR[i]:=0;
PAYMENTARR[i]:=0;
end; {ends for statment}
End; {Declare and Initialise Variables}
Procedure PutDataIntoArray;
{This procedure puts the data into the arrays}
Begin
while(idnum<>0) and (payment<>0) and (payment=1350) and (payment=1620) and (payment=1800) and (payment=1650) and (payment=1980) and (payment=2200) do
begin
writeln('Invalid value, please enter another value');
readln(idnum);
readln(payment);
end;{ends while statement}
j:=j+1;
IDNUMARR[j]:=idnum;
PAYMENTARR[j]:=payment;
End; {Put Data Into Array}
Procedure DetermineStatisticsInformation;
{This procedure determines which masqueraders belong to which group, tallys the total persons in a section and totals the amount of money paid in each section for costumes}
Begin
For j:=1 to size do
begin
if(PAYMENTARR[j]=1350) and (PAYMENTARR[j]=1650) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section1');
section1:= section1+1;
totm1:= totm1+PAYMENTARR[j];
end;{ends if statement}
if(PAYMENTARR[j]=1620) and (PAYMENTARR[j]=1980) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section2');
section2:= section2+1;
totm2:=totm2+PAYMENTARR[j];
end;{ends if statement}
if(PAYMENTARR[j]=1800) and (PAYMENTARR[j]=2200)then
begin
writeln('Masquerader with memid:idnum[j] belongs to section3');
section3:= section3+1;
totm3:=totm3+PAYMENTARR[j];
end;{ends if statement}
End; {Determine Statistics Information}
Procedure PrintResults;
{This procedure outputs all information}
Begin
writeln('The number of masqueraders in section 1 is:', section1);
writeln('The number of masqueraders in section 2 is:', section2);
writeln('The number of masqueraders in section 3 is:', section3);
writeln('Total Amount of money paid in section 1 is:', totm1);
writeln('Total Amount of money paid in section 2 is:', totm2);
writeln('Total Amount of money paid in section 3 is:', totm3);
End. {Print Results}
我得到的错误是:77 / 11 paidup.pas错误:非法表达式
77 / 11 paidup.pas 错误:非法表达
77 / 11 paidup.pas 致命:语法错误,;预期但找到标识符 PRINTRESULTS
您仍然缺少结束语句来匹配For j:=1 to size do in procedure DetermineStatisticsInformation.
此外,您的 while 条件 while(idnum<>0) and (payment<>0) and (payment=1350) and (payment=1620) and (payment=1800) and (payment =1650) and (payment=1980) and (payment=2200) do in procedure PutDataIntoArray 永远不会为真,因为 payment 同时等于 1350 和 1620 等...
Program PaidUp;
const
size=30;
var
payment,totm1,totm2,totm3:real;
section1,section2,section3,i,j,idnum:integer;
IDNUMARR:array[1..999] of integer;
PAYMENTARR:array[1..size] of real;
Procedure InitialiseVariables;
{This procedure initialises all variables used in the program}
Begin
idnum:=0;
payment:=0;
totm1:=0;
totm2:=0;
totm3:=0;
section1:=0;
section2:=0;
section3:=0;
i:=0;
j:=0;
End; {Initialise Variables}
Procedure DeclareandInitialiseArrays;
{This procedure declares and initialises all arrays used in the program}
Begin
For i:=1 to size do
begin
IDNUMARR[i]:=0;
PAYMENTARR[i]:=0;
end; {ends for statment}
End; {Declare and Initialise Variables}
Procedure PutDataIntoArray;
{This procedure puts the data into the arrays}
Begin
while(idnum<>0) and (payment<>0) and (payment=1350) and (payment=1620) and (payment=1800) and (payment=1650) and (payment=1980) and (payment=2200) do
begin
writeln('Invalid value, please enter another value');
readln(idnum);
readln(payment);
end;{ends while statement}
j:=j+1;
IDNUMARR[j]:=idnum;
PAYMENTARR[j]:=payment;
End; {Put Data Into Array}
Procedure DetermineStatisticsInformation;
{This procedure determines which masqueraders belong to which group, tallys the total persons in a section and totals the amount of money paid in each section for costumes}
Begin
For j:=1 to size do
begin
if(PAYMENTARR[j]=1350) and (PAYMENTARR[j]=1650) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section1');
section1:= section1+1;
totm1:= totm1+PAYMENTARR[j];
end;{ends if statement}
if(PAYMENTARR[j]=1620) and (PAYMENTARR[j]=1980) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section2');
section2:= section2+1;
totm2:=totm2+PAYMENTARR[j];
end;{ends if statement}
if(PAYMENTARR[j]=1800) and (PAYMENTARR[j]=2200)then
begin
writeln('Masquerader with memid:idnum[j] belongs to section3');
section3:= section3+1;
totm3:=totm3+PAYMENTARR[j];
end;{ends if statement}
End; {Determine Statistics Information}
Procedure PrintResults;
{This procedure outputs all information}
Begin
writeln('The number of masqueraders in section 1 is:', section1);
writeln('The number of masqueraders in section 2 is:', section2);
writeln('The number of masqueraders in section 3 is:', section3);
writeln('Total Amount of money paid in section 1 is:', totm1);
writeln('Total Amount of money paid in section 2 is:', totm2);
writeln('Total Amount of money paid in section 3 is:', totm3);
End. {Print Results}
我得到的错误是:77 / 11 paidup.pas错误:非法表达式 77 / 11 paidup.pas 错误:非法表达 77 / 11 paidup.pas 致命:语法错误,;预期但找到标识符 PRINTRESULTS
您仍然缺少结束语句来匹配For j:=1 to size do in procedure DetermineStatisticsInformation.
此外,您的 while 条件 while(idnum<>0) and (payment<>0) and (payment=1350) and (payment=1620) and (payment=1800) and (payment =1650) and (payment=1980) and (payment=2200) do in procedure PutDataIntoArray 永远不会为真,因为 payment 同时等于 1350 和 1620 等...