FreePascalで交通違反の罰金を計算する小さなプログラムを書いています。ソースコードは次のとおりです。
program TrafficFine;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes,SysUtils;
var
userInput : Char;
Fine : Integer;
TotalFine : Integer;
DaysPassed: Integer;
FineType : Integer;
begin
userInput := 'y';
while (userInput = 'Y') or (userInput = 'y') do
begin;
writeln('Enter type of fine:');
writeln('- Enter 1 for not wearing a seat-belt.');
writeln('- Enter 2 for driving without a license');
writeln('- Enter 3 for over-speeding.');
try
write('Enter value: ');
readln(FineType);
if(FineType <0) or (FineType>3) then
raise exception.Create('Fine type outside of range.');
case FineType of
1: Fine:= 500;
2: Fine:= 1000;
3: Fine:= 2000;
except
on e: exception do {line 39}
begin
Writeln('Error: '+e.message);
continue;
end;
write('Enter number of days passed since fine: ');
readln(DaysPassed);
if daysPassed<=10 then
TotalFine := Fine;
else if (daysPassed >10) and (daysPassed <=30) then
TotalFine := Fine * 2;
else
TotalFine := Fine*2 + Fine*0.5;
writeln('Total Fine is ' + IntToStr(TotalFine));
writeln('Would you like to calculate another fine: ');
readln(userInput);
end;
end.
次のエラーが発生します。
無料のPascalコンパイラバージョン2.4.4-2ubuntu1[2011/09/27]for i386 Copyright(c)1993-2010 by Florian KlaempflターゲットOS:Linux fori386コンパイル/home/ubuntu/Desktop/TrafficFine.pasTrafficFine.pas(39 、3)エラー:不正な式TrafficFine.pas(40,3)エラー:定数式が必要ですTrafficFine.pas(40,3)致命的:構文エラー、 ":"が必要ですが、 "識別子ON"が見つかりました致命的:コンパイルが中止されました
私は本から直接例に従ったので、どこが間違っているのかわかりません。どんな助けでもいただければ幸いです。ありがとう。