Pascal exitcode 201
我对这个程序有问题。该项目是为它是一个收银机Pascal exitcode 201,pascal,freepascal,Pascal,Freepascal,我对这个程序有问题。该项目是为它是一个收银机 Program Cash_Register; var ItemsPrices: array[1..20] of real; ItemsNames: array[1..20] of string; Item_Number: integer; NameNumber: integer; PriceTracker: integer; {1} NameTracker: integer; {1} To_E
Program Cash_Register;
var
ItemsPrices: array[1..20] of real;
ItemsNames: array[1..20] of string;
Item_Number: integer;
NameNumber: integer;
PriceTracker: integer; {1}
NameTracker: integer; {1}
To_End_Or_Not_To_End: string;
PriceNumber: integer; {0}
Subtotal: real;
gst_sum: real;
Final_Total: real;
const
GST: real = 0.125; {0.125}
Base: integer = 21; {21}
CR: string = #13; {#13}
LF: string = #10; {#10}
CRLF: string = #13#10; {CR + LF}
begin
{Variable and constant assignment}
PriceTracker:= 1;
NameTracker:= 1;
PriceNumber:= 0;
{This area below starts the name taking and price taking}
while (PriceTracker AND NameTracker) < Base do
begin
{This area below Asks the user for the name of the product}
Writeln('Please enter the name of product ');
write(Item_Number);
write(' please.');
readln(ItemsNames[Item_Number]);
{This area below asks the user for the price of said item}
Writeln('Please enter the price of product ');
write(Item_Number);
write(' please.');
readln(ItemsPrices[Item_Number]);
{This area below imcrements the counter by 1}
Item_Number:= Item_Number + 1;
{This area below asks the user if they want ot continue or not}
writeln('Do you want to stop entering items? [Yes/No]');
readln(To_End_Or_Not_To_End);
{This area below will determine the programs path}
if To_End_Or_Not_To_End = 'Yes' then
continue
else
break
end;
NameNumber:= Item_Number + 1;
PriceNumber:= Item_Number + 1;
Item_Number:= 1;
{This area below defines the code that will create the Subtotal}
while Item_Number < PriceNumber do
begin
Subtotal:= Subtotal + ItemsPrices[Item_Number];
Item_Number:= Item_Number + 1;
end;
gst_sum:= Subtotal * GST;
Final_Total:= Subtotal + gst;
Item_Number:= 1;
{This area below prints the List of items and prices in reciept form}
while Item_Number < NameNumber do
begin
write(ItemsNames[Item_Number]);
write(' Bz$ ');
write(ItemsPrices[Item_Number]);
write(CRLF);
Item_Number:= Item_Number + 1;
continue
end;
{This area below prints a reciept for the customer}
write('Subtotal'#9#9);
write(Subtotal);
writeln('GST tax 12.5%'#9#9 + 'Bz$');
write(gst_sum);
writeln('Total'#9#9 + 'Bz$');
write(Final_Total);
write(CRLF);
writeln('Tips:______________________________');
writeln(CRLF);
writeln('Total:_____________________________');
writeln(CRLF);
writeln('Print Name:________________________');
writeln(CRLF);
writeln('Signature__________________________');
end.
编程收银机;
变量
ItemsPrices:real的数组[1..20];
ItemsNames:字符串的数组[1..20];
项目编号:整数;
名称编号:整数;
PriceTracker:整数;{1}
NameTracker:整数;{1}
结束或不结束:字符串;
PriceNumber:整数;{0}
小计:实数;
商品及服务税总额:不动产;
最终总数:真实;
常数
商品及服务税:实际值=0.125;{0.125}
基数:整数=21;{21}
CR:string=#13;{#13}
LF:string=#10;{#10}
CRLF:string=#13#10;{CR+LF}
开始
{变量和常量赋值}
价格跟踪器:=1;
NameTracker:=1;
价格编号:=0;
{下面的这个区域开始取名和取价}
while(PriceTracker和NameTracker)
但是它编译了,它向我抛出了一个错误,说“ExitCode201让我兴奋”。我不想改变结构,我也不知道编译器发生了什么,因为它拒绝在不立即退出的情况下运行。我试图看到的是退出时会发生什么,因为我设法瞥见了启动时应该出现的文本。如果有人知道出了什么问题,请一定要告诉我。问题的原因就在你面前,但我怀疑你还不知道是什么问题 当这些行执行时
Writeln('Please enter the name of product ');
write(Item_Number);
write(' please.');
你看到的是
请输入产品名称0谢谢 这说明
项目编号的值为0(零)。你的下一个陈述是
readln(ItemsNames[Item_Number]);
您已将ItemNames
数组声明为包含元素1到20,因此没有ItemNames[0]
,这正是您的readln
试图读取的内容。你的孩子也是这样
readln(ItemsPrices[Item_Number]);
要解决此问题,请在循环开始时,在之前将值1指定给项目编号
接下来,添加语句
readln();
作为程序的最后一行(在结束之前。
)。这将在您有机会读取程序输出之前停止控制台窗口的关闭
以上内容至少可以让您开始调试程序。您需要学习如何自己调试其余部分。用谷歌自己搜索一些调试器教程,例如这一个
在调试自己的代码之前,在Pascal或任何其他编程语言中都将一无所获。其他人可能不同意,但在我看来,这可能是程序员需要的最重要的技能。请在这里发布问题之前做一些研究。提供了一些即时线索,甚至没有访问任何返回的链接。好吧,以目前的价格,noobs不再使用Delphi了……谢谢你,我会试试的,它应该可以工作,一切都可以。它可以工作!再次感谢@阿尔瓦罗哈贝苏斯:你有什么理由“不接受”我的答案吗?我的错,我一定是双击了