Hey guys below a program that I have as my homework.I am not askign for the code, but on how the calculatio is being done.I am asking about the mathematics part.I dont understand how it is being caluclated.

someone told me i need this formulas.
P = (rho * g * delta_h_water) + 1 atmosphere
V = pi r^2 * h
P2 = P1V1/V2

I still dont get it.Can someone please show me on the sample input given how the calculation is done and how the output being genertaed.Can someone shed a light on how to calculate this thing.
Please if u give formulas..specify to me what each variable is.

thanks alot

The Walid acqua Company (WAC) manages water storage facilities. They are considering a system of storing water in a series of connected vertical tanks. Each tank has a horizontal cross-sectional area of one square meter, but the tanks have different heights. The base of each tank is at ground level. Each tank is connected by a pipe to the previous tank in the series and by another pipe to the next tank in the
series. The pipes connecting the tanks are level and are at increasing heights (that is, the pipe connecting tank i to tank i+1 is at a higher level than the pipe connecting tank i to tank i-1.)
Tank 1 is open so that air and water can flow into it freely at the top. All the other tanks are closed so that air and water can flow in and out only through the connecting pipes. The connecting pipes are large enough that water and air can
flow through them freely and simultaneously but small enough that their dimensions can be ignored in this problem.
The series of tanks is filled by pouring water slowly into the top of tank 1, continuing until the water level reaches the top of tank 1.
As the water level rises above the connecting pipes, water flows among the tanks. WAC needs a program to compute the cubic meters of water that can be poured into the series of tanks before the water level reaches the top of tank 1.
The figure below illustrates a simple case involving only two tanks. After the filling procedure is completed, the air in the upper part of the second tank is compressed (its air pressure is greater than one atmosphere), so the water level in the second tank is lower than the water level in the first tank.
The following physical principles are helpful in solving this problem (some of these are approximations that are acceptable for the purposes of this problem):
1. Water flows downhill.
2. In an open space, the air pressure is equal to one atmosphere.
3. Air is compressible (the volume occupied by a given amount of air depends on pressure). Water is not compressible (the volume occupied by a given amount of water is constant, independent of pressure).
4. Air pressure is the same everywhere within a closed space. If the volume of the closed space changes, the product of the volume and the air pressure within the space remains constant. For example, suppose an enclosed airspace has an initial volume V1 and pressure P1. If the volume of the airspace changes to V2, then the new pressure P2 satisfies P1V1 = P2V2.
5. In a column of water below an airspace, the water pressure at a level D meters below the water surface is equal to the air
pressure at the surface plus 0.097·D atmospheres. This is true regardless of whether the airspace is open or enclosed.
6. In a connected body of water (for example, when two or more tanks are connected by pipes below the water line), the water
pressure is constant at any given level.
Input
The input consists of several test cases representing different series of water tanks. Each test case has three lines of data. The first line
contains an integer N (2 ≤ N ≤ 10) which is the number of tanks in the test case. The second line contains N positive floating point
numbers that are the heights, in meters, of tanks 1 through N. The third line contains N-1 floating point numbers. On this line, the kth
number represents the height above the ground of the pipe that connects tank k and tank k+1. The numbers on the third line are
increasing (each number is greater than the preceding number).
The last test case is followed by a line containing the integer zero.
Output
For each test case, print a line containing the test case number (beginning with 1) followed by the amount of water, in cubic meters,
that can be poured into tank 1 before the water level reaches the top of tank 1. Print the results with three digits to the right of the
decimal point.
Print a blank line after the output for each test case. Use the format of the sample output.


Sample input
2
10.0 8.0
4.0
0

Sample output for input:
Case 1:15.260

>>P = (rho * g * delta_h_water) + 1 atmosphere

int P;
int rho;
int g;
int delta_h_water;

//set those values to some values is not shown
P = (rho * g * delta_h_water) + 1 );

>>V = pi r^2 * h

#include <cmath>
double V;
const double pi = 3.1416 // add as many digits as you want
double r;
double h;

f = pi * pow(r, 2) * h;

>>P2 = P1V1/V2
Assume P1, P2, V1 and V2 are all integers. Make sure V2 is not 0.

int P1, P2, V1, V2;

p2 = (P1 * V1) / V2;

Can you please show me how the calculation on pen and paper is being done.
that is how we get into 15.260 please.

I have a feeling no one knows the answer for this, I asked many forums and no answer.I still cant figure out how we are getting 15.260..and how the calculation is being done.
I am doing nothing last 3 days, I have to write this progamming assignment yet I dont know how the calculation is done..I am going get a zero in my homework.please help

Hey guys below a program that I have as my homework.I am not askign for the code, but on how the calculatio is being done.I am asking about the mathematics part.I dont understand how it is being caluclated.

someone told me i need this formulas.
P = (rho * g * delta_h_water) + 1 atmosphere
V = pi r^2 * h
P2 = P1V1/V2

I still dont get it.Can someone please show me on the sample input given how the calculation is done and how the output being genertaed.Can someone shed a light on how to calculate this thing.
Please if u give formulas..specify to me what each variable is.

thanks alot

The Walid acqua Company (WAC) manages water storage facilities. They are considering a system of storing water in a series of connected vertical tanks. Each tank has a horizontal cross-sectional area of one square meter, but the tanks have different heights. The base of each tank is at ground level. Each tank is connected by a pipe to the previous tank in the series and by another pipe to the next tank in the
series. The pipes connecting the tanks are level and are at increasing heights (that is, the pipe connecting tank i to tank i+1 is at a higher level than the pipe connecting tank i to tank i-1.)
Tank 1 is open so that air and water can flow into it freely at the top. All the other tanks are closed so that air and water can flow in and out only through the connecting pipes. The connecting pipes are large enough that water and air can
flow through them freely and simultaneously but small enough that their dimensions can be ignored in this problem.
The series of tanks is filled by pouring water slowly into the top of tank 1, continuing until the water level reaches the top of tank 1.
As the water level rises above the connecting pipes, water flows among the tanks. WAC needs a program to compute the cubic meters of water that can be poured into the series of tanks before the water level reaches the top of tank 1.
The figure below illustrates a simple case involving only two tanks. After the filling procedure is completed, the air in the upper part of the second tank is compressed (its air pressure is greater than one atmosphere), so the water level in the second tank is lower than the water level in the first tank.
The following physical principles are helpful in solving this problem (some of these are approximations that are acceptable for the purposes of this problem):
1. Water flows downhill.
2. In an open space, the air pressure is equal to one atmosphere.
3. Air is compressible (the volume occupied by a given amount of air depends on pressure). Water is not compressible (the volume occupied by a given amount of water is constant, independent of pressure).
4. Air pressure is the same everywhere within a closed space. If the volume of the closed space changes, the product of the volume and the air pressure within the space remains constant. For example, suppose an enclosed airspace has an initial volume V1 and pressure P1. If the volume of the airspace changes to V2, then the new pressure P2 satisfies P1V1 = P2V2.
5. In a column of water below an airspace, the water pressure at a level D meters below the water surface is equal to the air
pressure at the surface plus 0.097·D atmospheres. This is true regardless of whether the airspace is open or enclosed.
6. In a connected body of water (for example, when two or more tanks are connected by pipes below the water line), the water
pressure is constant at any given level.
Input
The input consists of several test cases representing different series of water tanks. Each test case has three lines of data. The first line
contains an integer N (2 ≤ N ≤ 10) which is the number of tanks in the test case. The second line contains N positive floating point
numbers that are the heights, in meters, of tanks 1 through N. The third line contains N-1 floating point numbers. On this line, the kth
number represents the height above the ground of the pipe that connects tank k and tank k+1. The numbers on the third line are
increasing (each number is greater than the preceding number).
The last test case is followed by a line containing the integer zero.
Output
For each test case, print a line containing the test case number (beginning with 1) followed by the amount of water, in cubic meters,
that can be poured into tank 1 before the water level reaches the top of tank 1. Print the results with three digits to the right of the
decimal point.
Print a blank line after the output for each test case. Use the format of the sample output.


Sample input
2
10.0 8.0
4.0
0

Sample output for input:
Case 1:15.260

It is much easier to explain with a diagram. You have a tank that is open and that is 10 meters high. It has a cross section of 1 square meter, so its volume is 10 cubic meters. 1 cubic meter of water is 1000 liters. A liter of water has a mass of one kilogram. Ignore the bottom four meters of the tanks and treat them as 6 meters high and 4 meters high each (that's subtracting the four meters above ground that the pipe attaching to each tank is. So you have to figure out the force that those 6 cubic meters of water are exerting on one side of the pipe from gravity, add in the atmospheric pressure, and that is the force exerting on one side of the pipe. On the other side of the pipe, you have the amount of water in the other tank, plus the pressure in the other tank exerting downward onto the water in that tank. Figure out how much force that needs to be to be equal to the force from the other tank and calculate the volume of the air and the water in tank 2. It'll be, assuming the answer you listed is correct, 1.62 cubic meters of water and 2.38 cubic meters of air (since we're treating tank 2 as a 4 meter high tank. Add the six cubic meters of water from tank 1 and you get 7.62 cubic meters. Add back in the 4 cubic meters each from tank 1 and tank 2 and you get 15.62 cubic meters of water. So basically, all 10 of the 10 cubic meters of tank 1 have water and 5.62 of the 8 cubic meters in tank 2 have water (again assuming that 15.62 is correct).

Like I said, it's hard to relate without pictures. The key is that the force of the water by gravity plus air pressure must be the same on each side of the pipe. Tank 1 is always filled to the brim. The air pressure is constant on the tank 1 side regardless of the amount of water that is in tank 2. The force on the pipe from tank 2 increases the more water you put into it and will grow to infinity if you actually succeed in completely filling tank 2 (obviously impossible in real life).

Note, water BELOW the level of the pipe exerts NO gravitational pressure on the pipe, plus no air density changes occur before both tanks are filled completely to the level of the pipe (at least this is true when the tanks are being filled slowly and there are only two of them).

This article has been dead for over six months. Start a new discussion instead.