我被分配了一个程序来写。这是说明
问题解决和编程
您需要编写伪代码或绘制一个接受客户信息的流程图(名字,姓氏,性别,汽车型号,汽车类别,保险公司,TOC,是否安装了防盗设备) ,高级和汽车价值)。根据电子表格部分的任务B中给出的计算标准计算每个客户的补偿金额。
最后你要: 一个。计算保险车辆的数量完全全面 湾找到最高的车辆成本 C。计算安装防盗机制的所有者的百分比 d。提示用户输入客户的姓名并搜索并显示客户的信息,包括要支付的赔偿金。
这里是代码`
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"
结束。
我收到这些错误
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
答案 0 :(得分:5)
这是不正确的:
FOR X = 1 to 30 DO
for命令的语义意味着X被赋值为1,所以你应该使用
For X := 1 to 30 do
这是不正确的:
ReadLn Category[X]
读取是一个过程,它的参数应该用括号分隔。
ReadLn(Category[X]);
这又是不正确的:
Until "stop"
直到需要一个布尔表达式(任何返回true或false的表达式)。字符串不是布尔表达式。
ENDIF
帕斯卡不是基本的。 if命令不会在结束时“结束”。结束的是由BEGIN启动的命令块,因此Pascal中没有ENDIF,ENDCASE,ENDWHATEVER,只有BEGIN和END。
END;
这是不正确的:
Read Antitheft installed[X]
除了在程序参数列表中不使用括号的错误(WriteLn和ReadLn都是来自系统单元的程序),你试图使用其名称中有空格的变量,这是不允许的。
这是不正确的:
Count=Count+1
Pascal赋值运算符为:=
,而不是=
。如果要增加变量,可以使用Inc(Count)递增变量。
这是不正确的:
IF V_O_C <1 and TOC= "FC" then
对于Pascal,and
运算符优先于relop运算符(=
和<
),编译器将首先运行and
,从而产生以下等效表达式。
IF (V_O_C < (1 and TOC)) = "FC" then
您的代码中有太多错误。