Quote
You are to assume the role of a secret agent whose mission is to sneak up and drill a small hole in the base of a storage tank that holds a special rocket fuel. The tank is 20 feet high; it is full, and you want it to be empty. The diameter of the tank is 8 feet, and you are going to drill a hole that is only 2 inches in diameter. The velocity of the fuel out the hole is related to the height of the fluid remaining in the tank and is calculated as 8.02 times the square root of the fluid level (in feet) remaining in the tank.
Calculate how long it will take to drain the tank. Display the progress of the program as the simulation passes each 1-minute interval by showing the time and the height of the fluid remaining in the tank. At the end of the simulation, report the total time it took to drain the tank in hours:minutes:seconds format (correct answer: 42 minutes and 45 seconds).
Math things to keep in mind:
[*]Fluid through the hole in an interval is velocity (in feet per second) times area of hole (in square feet), giving a result in cubic feet per second.
[*]If you multiply the velocity by nozzle area, you get cubic feet. Use this to calculate the changing height of fluid in the tank. Then calculate a new velocity.
[*]Remember, radius is one half of a diameter, and volume of a cylinder is pi times radius squared times height.
Calculate how long it will take to drain the tank. Display the progress of the program as the simulation passes each 1-minute interval by showing the time and the height of the fluid remaining in the tank. At the end of the simulation, report the total time it took to drain the tank in hours:minutes:seconds format (correct answer: 42 minutes and 45 seconds).
Math things to keep in mind:
[*]Fluid through the hole in an interval is velocity (in feet per second) times area of hole (in square feet), giving a result in cubic feet per second.
[*]If you multiply the velocity by nozzle area, you get cubic feet. Use this to calculate the changing height of fluid in the tank. Then calculate a new velocity.
[*]Remember, radius is one half of a diameter, and volume of a cylinder is pi times radius squared times height.
That was the question posed to me, and here is the class i created, my math is way wrong. I've screwed around with it for a few days and everything i do is wrong. my teachers are all dumb and can't figure it out either. partly because the wording on the problem is so sketchy.
class DrainTank
{
final double PI = 3.141592654;
// instance variables
private double myHeight = 20;
private double myLiquid;
private double myRadius = 4;
private double myHole = (PI * Math.pow((1/12),2));
private double myVelocity;
private double myLiquidInterval = 0;
private int time = 0;
private int loop;
// constructor
DrainTank()
{
}
// methods
void drain()
{
myLiquid = (PI*Math.pow(myHole,2)*myHeight);
do{
myVelocity = (8.02 * Math.sqrt(myHeight) * (PI / 144));
//System.out.println("myVelocity: " + myVelocity);
myLiquidInterval = (myVelocity * Math.pow(myHole,2));
//System.out.println("myLiquidInterval: " + myLiquidInterval);
myLiquid = (myLiquid - myLiquidInterval);
//System.out.println("myLiquid: " + myLiquid);
myHeight = (myLiquid/(PI * Math.pow(myHole,2)));
//System.out.println("myHeight: " + myHeight);
time++;
if((time % 60)==0)
{
loop++;
System.out.print("Time: " + time + " " + myHeight);
if((loop%10) == 0) { System.out.println("");}
}
}while(myLiquid > 0);
}
}

New Topic/Question
Reply




MultiQuote




|