Saturday, February 7, 2009

Parkking Cost

In this case we would calculate of parking cost.For example,if price of car parkking in once clock is 2000 and after that increase 1000 every clock.And for motorcycle is 1000 in once clock and after that increase 500 every clock.And then cost maksimum is 7500 for motorcycle and 15000 for a car.We will finish case like that with statement like this :

Program parking; 
uses wincrt; 
var kendaraan : string; 
j1,m1,d1,j2,m2,d2,j3,m3,d3 : integer; 
T :longint; 
bayar : integer; 
begin  
writeln ('Program price of car and motorcycle'); 
writeln ('Input Time in and time out (clock, minute, sekon) separated with space'); 
write('Write type of transportation(car or motorcycle) : ' ); readln(kendaraan); 
write('Input time In : '); readln(j1,m1,d1); 
write('Input time Out : '); readln(j2,m2,d2);  
T := (j2*3600+m2*60+d2)-(j1*3600 + m1*60 +d1);  
j3 := T div 3600; 
m3 := (T mod 3600) div 60; 
d3 := (T mod 3600) mod 60;  
if (m3>0) or (d3>0) then 
j3:=j3+1;  
if kendaraan = 'motorcycle' then 
begin 
if j3<=2 then 
bayar := 1000 
else bayar :=1000+500*(j3-2); 
if bayar >=7500 then bayar := 7500; 
end;  
if kendaraan ='car' then 
begin 
if j3 <=2 then 
bayar := 2000 
else bayar := 2000+1000*(j3-2); 
if bayar >=15000 then bayar := 15000; 
end;  
write('Biaya Parkir : ',bayar);  
readln; 
end.

if we run the statement,we are get output like this :

parkking

No comments: