Question: If..then not working?

Why is the max height always 0 in this code? Thanks.

 

>restart;

>a := proc (t) options operator, arrow; (-1)*.12*t^4+12*t^3-380*t^2+4100*t+220 end proc

printf("%10.10s    %15.15s\n", "Time (hrs)", "Height (meters)");

printf("%10.10s    %15.15s\n", "----------", "---------------");

amax := 0; tmax := 0;

for t to 4 do

alt := a(t);

printf("%6d        %10.0f\n", t, alt);

if alt > amax then

amax = alt;

tmax = t

end if

end do;

printf("\nMaximum altitude: %6.0f meters.\nTime of peak: %3d hours\n", tmax, amax);


Time (hrs)    Height (meters)
----------    ---------------
     1              3952
     2              6994
     3              9414
     4             11277

Maximum altitude:      0 meters.
Time of peak:   0 hours

 

P.S. How the heck are you supposed to copy code into this editor? It keeps copying it as an image instead of text!

Please Wait...