PROGRAM cool ! numerical solution of Newton's law of cooling CALL initial(t,T_coffee,T_room,r,delta_t,tmax,nshow) LET counter = 0 ! initialize counter for clarity DO while t <= tmax CALL Euler(t,T_coffee,T_room,r,delta_t) LET counter = counter + 1 ! number of iterations IF mod(counter,nshow) = 0 then CALL output(t,T_coffee,T_room) END IF LOOP END SUB initial(t,T_init,T_room,r,delta_t,tmax,nshow) ! time is keyword in True BASIC so cannot be used as a variable LET t = 0 ! time LET T_init = 82.3 ! initial coffee temperature (C) LET T_room = 17 ! room temperature (C) INPUT prompt "cooling constant r = ": r INPUT prompt "time step dt = ": delta_t INPUT prompt "duration of run = ": tmax ! minutes INPUT prompt "time between output of data = ": tshow LET nshow = round(tshow/delta_t) CALL output(t,T_init,T_room) END SUB SUB Euler(t,T_coffee,T_room,r,delta_t) LET change = -r*(T_coffee - T_room)*delta_t LET T_coffee = T_coffee + change LET t = t + delta_t END SUB SUB output(t,T_coffee,T_room) IF t = 0 then PRINT PRINT "time (min)","T_coffee","T_coffee - T_room" PRINT END IF PRINT t,T_coffee,T_coffee - T_room ! show results on screen END SUB