Pascal I';我得到一个错误:非法表达式
我得到这个错误:Pascal I';我得到一个错误:非法表达式,pascal,Pascal,我得到这个错误: illegal expression and Fatal: Syntax error, ; expected but : found Pascal代码如下所示: Program PaidUp; const size=30; var payment,totm1,totm2,totm3:real; section1,section2,section3,i,j,idnum:integer; IDNUMARR:array[1..999] of integer;
illegal expression and Fatal: Syntax error, ; expected but : found
Pascal代码如下所示:
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
IDNUMARR:array[1..999] of integer;
PAYMENTARR:array[1..size] of real;
For i:=1 to size do
begin
idnum[i]:=0;
payment[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}
set j:=j+1;
idnum[j]:=idnum;
payment[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(payment[j]=1350 and payment[j]=1650) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section1');
section1:= section1+1;
totm1:= totm1+payment[j];
end;{ends if statement}
if(payment[j]=1620 and payment[j]=1980) then
begin
writeln('Masquerader with memid:idnum[j] belongs to section2');
section2:= section2+1;
totm2:=totm2+payment[j];
end;{ends if statement}
if(payment[j]=1800 and payment[j]=2200)then
begin
writeln('Masquerader with memid:idnum[j] belongs to section3');
section3:= section3+1;
totm3:=totm3+payment[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}
程序PaidUp;
常数
尺寸=30;
变量
付款总额1、2、3:实际金额;
第1节、第2节、第3节,i、j、idnum:整数;
IDNUMARR:整数的数组[1..999];
PAYMENTARR:real的数组[1..size];
程序变量;
{此过程初始化程序中使用的所有变量}
开始
idnum:=0;
付款:=0;
totm1:=0;
totm2:=0;
totm3:=0;
第1节:=0;
第二节:=0;
第三节:=0;
i:=0;
j:=0;
结束;{初始化变量}
程序声明和初步声明;
{此过程声明并初始化程序中使用的所有数组}
开始
IDNUMARR:整数的数组[1..999];
PAYMENTARR:real的数组[1..size];
对于i:=1到尺寸do
开始
idnum[i]:=0;
付款[i]:=0;
结束;{station的结束}
结束;{声明并初始化变量}
将数据放入数组的过程;
{此过程将数据放入数组}
开始
而(idnum0和payment0和payment=1350和payment=1620和payment=1800和payment=1650和payment=1980和payment=2200)则
开始
writeln('无效值,请输入另一个值');
readln(idnum);
readln(付款);
结束;{结束while语句}
设置j:=j+1;
idnum[j]:=idnum;
付款[j]:=付款;
结束;{将数据放入数组}
程序决定论信息;
{此程序确定哪些伪装者属于哪一组,统计一个部分的总人数,并计算每个部分为服装支付的总金额}
开始
对于j:=1到尺寸do
开始
如果(付款[j]=1350,付款[j]=1650),则
开始
writeln('memid:idnum[j]的伪装器属于section1');
截面1:=截面1+1;
totm1:=totm1+付款[j];
结束;{如果语句结束}
如果(付款[j]=1620,付款[j]=1980),则
开始
writeln('memid:idnum[j]的伪装器属于section2');
第2节:=第2+1节;
合计2:=合计2+付款[j];
结束;{如果语句结束}
如果(付款[j]=1800,付款[j]=2200),则
开始
writeln('memid:idnum[j]的伪装器属于第3节');
第3节:=第3节+1;
合计3:=合计3+付款[j];
结束;{如果语句结束}
结束。{确定统计信息}
程序打印结果;
{此过程输出所有信息}
开始
writeln('第1节中的伪装者数量为:',第1节);
writeln('第2节中的伪装者数量为:',第2节);
writeln(“第3节中的伪装者数量为:”,第3节);
书面形式(“第1节中支付的总金额为:”,总计1);
书面形式(“第2节中支付的总金额为:”,总计m2);
书面形式(“第3节中支付的总金额为:”,总计3);
结束。{打印结果}
这是错误的,其他类似的行:
if(payment[j]=1350 and payment[j]=1650) then
让它看起来像是(..)和(..)那么代码充满了错误,永远不会编译
if(payment[j]=1620) and (payment[j]=1980) then
四,。设置j:=j+1;
你认为会发生什么事??
我想你只是想增加j
j:=j+1;
可能还有很多其他的…哦,我是用模块化的格式写的,因为我的教授说,编译器有没有告诉你错误发生在哪几行?这将是一个很好的信息,包括在你的问题。是的,他们都落在31/15嗯…谢谢你,但就像我说的,我非常新的这种类型的软件…像2天新的…不要误会我,我非常感谢你的回答,我会尽我最大的努力来解决它…我可以问一个问题吗?你的意思是在我付款的地方使用PAYMENTARR吗?是的。您的数组变量是PAYMENTARR和IDNUMARR。所以你必须使用PAYMENTARR[j]和Idnumar[j]哦,好吧,我相信我已经解决了问题……所以我重新审视我所做的。。。感谢你们的持续支持!嗯…我不知道如何重新发布整个代码你能告诉我怎么做吗?xDoh好的,谢谢,我会修正你们说要修正的内容,我会重播,让你们这些好朋友重新评估……谢谢你们的支持help@Josiah,如果您对代码进行了重大更改,但仍有问题,则最好接受此问题的其中一个答案(如果有帮助),然后发布一个新问题和任何新问题。如果您更改此问题中的代码,将使您已经收到的答案无效……这不是网站的工作方式。@JimLewis oki我会,我会重新发布