Computing volume of a cone plus hemisphere

completely new to the language, here is the formula i was given to compute the volume of a cone plus hemisphere,
" v = [ (1/3) X pi X r-squared X h ] + [ (2/3) X pi X r-cubed ]

where...
v = volume of ice cream (cubic inches)
r = radius of cone (inches)
h = height of cone from tip to brim (inches)
pi = PI (use 3.14159)
Density of ice cream = 0.0202 pounds per cubic inch"
I am completely lost and could really use some help.
closed account (48T7M4Gy)
1
2
3
float pi = 3.14159, r = 0; h = 0; rho = 0.0202;
cin >> r >> h;
float v = pi * r * r * ( h/3 + r * 2/3); 
Thank you so much! any good techniques on identify the variables??
closed account (48T7M4Gy)
I'm not sure I understand what you mean.

To make the program clearer you could choose variable names so that 3 becomes,
float volume = pi * radius * radius * ( height/3 + radius * 2/3);
Topic archived. No new replies allowed.