% sample15.t % reading to the eof % reads prices of items from a file and calculates the total % price and the average price var price, total_price : real var count : int count := 0 total_price := 0 loop get skip exit when eof % when there are no more prices in the file count := count +1 % let's count how many prices there are get price total_price := total_price + price end loop put "There were ",count," items on the list." put "The total was ", total_price if count not=0 then % don't want to divide by 0 put "The average price was ",total_price/count end if