


class X
creation
make
feature
distance, speed, per_klom, price: REAL
litres, time, cost: REAL
make is
-- read the distance, speed, mileage, and cost of petrol
-- show the time and cost for the trip
do
io.putstring ("%NEnter the distance covered: ")
io.readreal
distance := io.lastreal
io.putstring ("%NEnter the average speed: ")
io.readreal
speed := io.lastreal
io.putstring ("%NEnter the litres per klom: ")
io.readreal
per_klom := io.lastreal
io.putstring ("%NEnter the price of a litre of petrol: ")
io.readreal
price := io.lastreal
time := distance / speed
litres := distance * per_klom
cost := litres * price
io.putstring ("%NThe time for the trip is")
io.putreal (time)
io.putstring (" hours")
io.putstring ("%NThe cost of the trip is $")
io.putreal (cost))
end -- make
end -- class X