Thank you for your quick reply
The code is actually from a task from Hacker Rank. It is actually my task to create the Calculate class. The Solution class is already created and given in the task and cannot be modified. What I don't understand is why they have used the .main method. If I were to create the Solution class, I would have never call the .get_Vol method that way. I want to know the reason why they have done so.
The task problem description is below:
You are given a class Solution and its main method in the editor. In each test cases, it takes an input ch which represents a choice of the following:
ch=1 represents the volume of a cube that has to be calculated where a represents the length of the sides of the cube.
ch=2 represents the volume of a cuboid that has to be calculated where l,b,h represent the dimensions of a cuboid.
ch=3 represents the volume of a hemisphere that has to be calculated where r represents the radius of a hemisphere.
ch=4 represents the volume of a cylinder that has to be calculated where r,h represent the radius and height of the cylinder respectively.
Your task is to create the class Calculate and the required methods so that the code prints the volume of the figures rounded to exactly 33 decimal places.
Note: Use Math.PI or 3.141592653.14159265 as the value of pi.
Input Format
First line contains T, the number of test cases. Each test case contains ch, representing the choice as given in the problem statement.
When ch=1, Next line contains a, length of the sides of the cube.
When ch=2, Next three lines contain l, b, h representing length, breadth and height of the cuboid respectively. l, b, h will be in three separate lines
When ch=3, Next line contains r, the radius of the hemisphere
When ch=4, Next two lines contain r, h representing the radius and height of the cylinder respectively. r, h will be in two separate lines.
Note: You have to determine the data type of each parameter by looking at the code given in the main method.
Constraints
1≤ch≤41≤ch≤4
−100≤a,l,b,h,r≤100−100≤a,l,b,h,r≤100
There will be at most 33 digits after decimal point in input.
Output Format
For each test case, print the answer rounded up to exactly 3 decimal places in a single line. For example, 1.2345 should be rounded to 1.235, 3.12995 should be rounded to 3.130.