Lesson topics
Demo 8
program demo8
c This program computes in double precision the volume and
c surface area of a ball. The radius is input by the user.
c Note that all numbers, except integer exponents, are
c written with double precision notation. Results are
c printed in a table with write and format statements.
double precision r, vol, surf, pi
parameter (pi = 3.1415926535897932D0)
print *, "What is the radius of the ball ?"
read *, r
vol = (4D0 * pi * r ** 3)/3D0
surf = 4D0 * pi * r * r
print *
write (*,10) "Radius", "Volume", "Surface Area"
10 format (t10,a,t32,a,t57,a)
write (*,20) r, vol, surf
20 format (f20.15,t22,f24.15,t48,f24.15)
end