-->
当前位置:首页 > 题库

PROGRAMMING:Circular volume calculator

Luz5年前 (2021-05-10)题库549
This problem requires the realization of a commonly used circular volume calculator. The calculation formula is as follows:
-Sphere volume $$v = - frac {4} {3} PI R ^ 3 $$, where $$R $$is the radius of the sphere.
-Cylinder volume $$v = - pi R ^ 2 h $$, where $$R $$is the radius of the bottom circle and $$h $$is the height.
-Cone volume $$v = - frac {1} {3} PI R ^ 2 h $$, where $$R $$is the radius of the base circle and $$h $$is the height.
###Input format:
Before each calculation, it is required to output the following interface:
```
1-Ball
2-Cylinder
3-Cone
other-Exit
Please enter your command:
```
Then an integer instruction is read in from the standard input.
###Output format:
If the read instruction is 1 or 2 or 3, the corresponding volume calculation is performed; If it is any other integer, the program ends.
-When the input value is 1, print "please enter the radius:" before calculating the volume of the sphere, and then read in the radius of the sphere to complete the calculation;
-When the input value is 2, print "please enter the radius and the height" before calculating the volume of the cylinder, and then read in the radius and height of the bottom circle to complete the calculation;
-When the input value is 3, print "please enter the radius and the height" before calculating the volume of the cone, and then read in the radius and height of the bottom circle to complete the calculation.
The calculation results are output in one line, with two decimal places reserved.
###Input example:
```in
one
two
three
2.4 3
0
```
###Output example:
```out
1-Ball
2-Cylinder
3-Cone
other-Exit
Please enter your command:
Please enter the radius:
thirty-three point five one
1-Ball
2-Cylinder
3-Cone
other-Exit
Please enter your command:
Please enter the radius and the height:
eighteen point one zero
1-Ball
2-Cylinder
3-Cone
other-Exit
Please enter your command:
```






answer:If there is no answer, please comment