Not really a coding problem, but a math problem.
So let’s go through it real quick:
You got the height of the liquid h, the diameter of the tank d and the total volume of the tank.
The tank is a cylinder which is a special kind of prism which has a volume of profile * height. The still liquid in the tank is the same, hence we only need the percentage the liquid is filling in the circle to calculate the actual volume.
Meaning we need “green area” divided by “circle area”.
What do we see in the pictue? We have a triangle and the liquid below.
The liquid PLUS the triangle are a segment of the circle. So we need it’s area and then subtract the triangle. The sides of the triangle are the diameter, the height is the diameter minus h. Because the triangle can be divided into two rectangular triangles, we can use the sinus to calculate the missing angles. With those we can calculate both the area of the triangles, as well as of the circle-segment. Their difference is the green area. And that divided by the area of the circle and then multiplied by the total volume is the actual volume.