HP Forums

Full Version: Moments of Inertia
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Source:

Browne, Michael E. Ph. D "Schaum's Outlines: Physics for Engineering and Science" 2nd. Ed McGraw Hill: New York. 2010.

HP Prime: INERTIA

This program demonstrates the use of CHOOSE and CASE

Code:

EXPORT INERTIA( )
BEGIN
// EWS 2014-06-24
LOCAL c,a,b,m,r;

CHOOSE(c, "Moment of Inertia", 
{"Square", "Rectangle", "Cylinder", "Sphere", "Hoop"});

CASE 

IF c==1 THEN  INPUT({m,a});
RETURN m*a^2/6; END;

IF c==2 THEN INPUT({m,a,b});
RETURN m*(a^2+b^2)/12; END;

IF c==3 THEN INPUT({m,r});
RETURN m*r^2/2; END;

IF c==4 THEN INPUT({m,r});
RETURN 2*m*r^2/5; END;

IF c==5 THEN INPUT({m,r});
RETURN m*r^2; END;

DEFAULT KILL; END;

END;
Reference URL's