我的pascal作业需要修复此代码

-5 pascal freepascal

我被分配了要编写的程序。这是说明

问题解决与编程

  1. 保险公司对根据NMTRO进行的研究可以更好地为客户提供帮助的软件感兴趣。该软件应进行试运行,每天最多可接待30位客户。

您需要编写一个伪代码或绘制流程图,以接受客户的信息(名字,姓氏,性别,汽车型号,汽车类别,保险公司,TOC,是否已安装防盗设备,Premium和汽车价值)。根据电子表格部分任务B中给出的计算标准,为每个客户计算补偿金。

最后,您将要:计算完全综合保险的车辆数量b。找到最高的车辆成本c。计算安装防盗机制的所有者的比例d。提示用户输入客户名称,并搜索并显示客户信息,包括要支付的赔偿金。

  1. 设计并实现一个跟踪表,该表接受6个成员的数据(与电子表格相同的数据)。该表应跟踪汽车,TOC,保费,防盗安装和保险付款的价值。应计算所有客户的总保费

这是代码`

VAR
     First_Name, Last_Name, Model, Insurance_company, stop: array[1..30] of string;
     Compensation, V_O_C, P_O_A, A_O_C: array [1..30] of real;
     Gender: array [1..30] of char;
     T_O_C, Premium, X, Count, CountA, Highest, Category: array [1..30]of integer;
     Antitheft_installed: array [1..30] of boolean;

Begin
   Count:=0;
   CountA:=0;
   Highest:=0;
    FOR X = 1 to 30 DO
   Repeat
   Writeln ('Please enter First_Name');
   Readln (First_Name[X]);
   Writeln ('Please enter Last_Name');
   Read Last_ Name [X]
   Writeln ('Please enter Gender, M or F');
   Readln Gender[X]
   Until "stop"
   IF Gender<>M and Gender <>F then
   Print "You can only enter M or F for Gender"
  ENDIF
 Repeat
 Writeln "Please enter Model"
Read Model[X]
Writeln "Please Enter number corresponding with Category of car"
Writeln "Please Enter 1 for LCR-70"
Writeln "Please Enter 2 for LCR-71"
Writeln "Please Enter 3 for LCR-72"
Writeln "Please Enter 4 for LCR-73"
Read Category[X]
Until "stop"
If category >=5 then
Writeln "Please select one of the options above"
ENDIF  
Repeat
Writeln "Please enter 1 if Type Of Coverage is FC"
Writeln "Please enter 2 if Type Of Coverage is TPO"
Read TOC[X]
 Until "stop"
IF TOC >=3 Then
Writeln "Only 1 or 2 can be entered here"
ENDIF
Repeat
Writeln "Please enter Antitheft installed Yes or No"
Read Antitheft installed[X]
IF Antitheft = "yes" then
CountA =CountA+1
P_O_A= CountA/Max * 100
ENDIf
Writeln "The percentage is" P_O_A[X]
Writeln "Press 1 for BBC"
Writeln "Press 2 for Nationwide"
Writeln "Press 3 for IWCI"
Writeln "Press 4 for Statefarm"
Read Insurance company[X]
IF Insurance_company =1 then
Writeln "Your premium is $2700"
ENDIF
IF Insurance_company =2 then
Writeln "Your premium is $3500"
ENDIF
IF Insurance_company =3 then
Writeln "Your premium is $1675"
ENDIF
IF Insurance_company =4 then
Writeln "Your premium is $1950"
ENDIF
IF insurance_company>= 5 then
Writeln "Please choose one of the options above"
ENDIF
Read Premium
 Writeln "Please enter value of car"
 Read V_O_C[X]
 While TOC= " FC" Do
 Count=Count+1
  ENDWhile
  Writeln "The total number of vehicles fully comprehensively insured is" Count[X]
  IF V_O_C > Highest    then
  Highest= V_O_C

  Writeln "The Highest value of car is", Highest[X]
  IF V_O_C <1 and TOC= "FC" then
  Compensation= V_O_C * 0.5 Else
  IF A_O_C >=2 and A_O_C <=4 and TOC= "FC" then
  Compensation= V_O_C * 0.4 Else    
  IF A_O_C >=5 and A_O_C <=7 and TOC= "FC"   then
  Compensation= V_O_C * 0.3 Else
  IF A_O_C >=8 and A_O_C <=10 and TPO= "FC"   then
  Compensation= A_O_C * 0.2 Else
  IF A_O_C >10 and TOC= "FC"   then
  Compensation= V_O_C * 0.1 Else
  Compensation= V_O_C * 0
  Writeln "The Frist name of the customer is" First_Name[X]
  Writeln "The Last name of the customer is" Last_Name[X]
  Writeln "The customer Gender is" Gender[X]
  Writeln "The model of car the customer own is" Model[X]
  Writeln "The category of car customer own is" Category[X]
  Writeln "The insurance company the customer is with is" Insurance_ Company[X]
  Writeln "The type of coverage for customer is" TOC[X]
  Writeln "The customer antitheft yes or no" Antitheft_ installed[X]
  Writeln "The premium for customer is" Premium[X]
  Writeln "The value of car for customer is" V_O_C[X]
  Writeln "The customer compensation is" Compensation[X]
  Writeln "Enter 11 to add a customer"
Run Code Online (Sandbox Code Playgroud)

结束。

我得到这些错误

17 / 26 clunis.pas Error: Type mismatch
17 / 27 clunis.pas
 Error: Incompatible types: got "Array[1..30] Of LONGINT" expected "LONGINT"
19 / 13 clunis.pas
 Fatal: Syntax error, UNTIL expected but identifier LAST_ found
Run Code Online (Sandbox Code Playgroud)

Jor*_*ldo 5

这是不正确的:

FOR X = 1 to 30 DO
Run Code Online (Sandbox Code Playgroud)

for命令的语义意味着将X赋值为1,因此应改用

For X := 1 to 30 do
Run Code Online (Sandbox Code Playgroud)

这是不正确的:

ReadLn Category[X]
Run Code Online (Sandbox Code Playgroud)

读取是一个过程,它的参数应以括号分隔。

ReadLn(Category[X]);
Run Code Online (Sandbox Code Playgroud)

同样,这是不正确的:

Until "stop"
Run Code Online (Sandbox Code Playgroud)

直到期望一个布尔表达式(任何返回true或false的表达式)。字符串不是布尔表达式。

ENDIF
Run Code Online (Sandbox Code Playgroud)

Pascal不是基本的。最后,if命令不会“结束”。结束的是由BEGIN启动的命令块,因此Pascal中没有ENDIF,ENDCASE,ENDWHEREVER,只有BEGIN和END。

END;
Run Code Online (Sandbox Code Playgroud)

这是不正确的:

Read Antitheft installed[X]
Run Code Online (Sandbox Code Playgroud)

除了在过程参数列表周围不使用括号的错误(WriteLn和ReadLn都是系统单元中的过程)之外,您还尝试使用变量名称内带有空格的变量,那是不允许的。

这是不正确的:

 Count=Count+1
Run Code Online (Sandbox Code Playgroud)

Pascal赋值运算符:=不是=。如果要递增变量,可以使用Inc(Count)递增变量。

这是不正确的:

 IF V_O_C <1 and TOC= "FC" then
Run Code Online (Sandbox Code Playgroud)

对于Pascal,and运算符的优先级高于relop运算符(=<),编译器将首先操作and,从而产生以下等效表达式。

 IF (V_O_C < (1 and TOC)) = "FC" then
Run Code Online (Sandbox Code Playgroud)

您的代码中有太多错误。

  • @RobertRichards我怀疑老师希望学生们花一些时间自己学习语言语法,因为有很多免费的信息可以这样做。让他花一个小时左右的时间学习[此Pascal教程](http://www.tutorialspoint.com/pascal/pascal_program_structure.htm)。由此,他应该能够解决大多数问题。如果还有棘手的问题,可以在这里询问。 (2认同)