Pascal Help

Associate
Joined
19 Dec 2007
Posts
410
Location
US
Hi,

I am trying to make a programme which will find the current years depreciation expense based on the Double Depreciation rate method however I keep getting errors saying there is an illegal expression, could someone tell me what Im doing wrong?

Code:
program depreciation;

var
cost, salvage, usefulife, numberofyears, x: integer;
rate: Extended;
depexp: Extended;
accdepexp: Extended;
begin

rate:=0;
x:=0;

write('Please enter the purchase cost');
readln(cost);
write('please enter the salvage value');
readln(salvage);
write('Please enter the useful life');
readln(usefulife);
write('Please enter years since purchase');
readln(numberofyears);


rate = (100/usefulife) * 2;

while x < numberofyears do;
	begin
		accdepexp:= cost - (cost * (rate/100));
		x := x+1;
	end;	
	
depexp:= (cost-accdepexp) * (rate/100);
write(depexp);
readln;
end.


The debug report reads:

Code:
*** Command: /usr/local/bin/ppc386 depreciation.pas -Mmacpas -Tdarwin -FU./intermediate-files/386 -k" -framework Carbon  -prebind" -Fi/Developer/MyStandardUnits -Fu/Developer/MyStandardUnits
Free Pascal Compiler version 2.2.0 [2007/11/14] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Darwin for i386
Compiling depreciation.pas
depreciation.pas(23,27) Error: Illegal expression
depreciation.pas(36) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Compilation NOT successful!
 
Last edited:
Back
Top Bottom