I'm trying to make an interactive calculator to solve the volume of a sphere. The thing is that I can't seem to make the program let the user input their own number for example, What if the user wants to the number four as the radius?

Here is what I have done:

``````% Here Are My Variables
var v : real
var r : real
const pi : real := 3.14159265358979323846
var choice : string
var numOfV : real
var numOfr : real

r := numOfr
v := 4/3 * pi * r ** numOfr

put "Hey! I hope I'm not bothering you but could you do me a huge favor? yes/no"
get choice
if  choice="yes" then
put "Yay! Thank you soooo much! I'll see you tonight then. Don't forget to bring that big brain of yours Haha!"
else
put "Ugh! You dont have a choice! You're coming over to my house...You know...Helping me understand the homework of course!"
end if

put "Later that day"

put "Hey you made it! please come in. Alright let's begin, shall we?"
put "Ok the question say's that we need to find the volume of the sphere! but what variable do you want to use for v?"
get numOfV
put "Ok! what number do you want to use for r?"
get numOfr
put "Ok! Let's solve for for V = ", numOfV, " and for r= ", numOfr, " Alright?"
put "OKAY! The volume of the sphere with the radius of ", numOfr, " units is ",v, " cubic units"``````

What language is this? The tag says c but it doesn't look like c to me.

Is there a clue in the Dani user name that has a `C++` in it, as in:

`Linzi c++`

Maybe it's some kind of generic code ?

`int radius = takeInInt( "Enter your desired radius: " ); // 'takeInInt' is user defined/coded //`

You could then put all this code into some function, say we name it: getVolume();

then you could code a big main loop like this:

``````do
{
getVolume();
}
while( more() );``````

Oh .. you also need to code for the function more, before you can call it in your C++ or C program.

But ... if you are looking for a nice language to start your coding of this little programming problem ... you will appreciate coding it easily, in Python.

Just to confirm the ease I suggested ...
you might like to see this quickly coded Python example:

``````# findVolForSphereGivenRadius.py #  # 2016-10-02 #

def takeInFloat( prompt ):
while True:
try:
return float( input( prompt ) )
except( ValueError ):
print( "Only decimal numbers are valid input here. Try again." )

if __name__ == "__main__":
from math import pi
PROMPT = "Input a radius to find the volume for that sphere: "
while True: