Question

Write a C program to compute volume of liquid in elliptical storage tank. Dimension of the tank is given (unit in meters] wid

Maybe it’s easier to imagine the tank on its side so that the depth gauge is inserted horizontally if you do this you must express the equation as a function of y and integrate that function.

Please use the ellipse formula, and compute the volume of liquid by trapezoidal integral and function you altered for the ellipse formula. MUST contain following function:

Void trapezoidal_integral (double depth, int n, double width, double height, double length, double *integral_result)

Sample output:

Enter the width of the tank (in meters): 9

Enter the height of the tank (in meters): 10

Enter the length of the tank (in meters): 12

Enter the specific depth on the measuring stick (in centimeters): 900

Depth 900 cm

Volume 804.02 cubic meters


Please use C as programming language. thx
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C CODE :

#include <stdio.h>

#include <math.h>

#include <stdlib.h>

double WIDTH;

double HEIGHT;

double LENGTH;

double DEPTH;

typedef double (*DFD) (double);

//Function of y in terms of x

double function (double x)

{

double a = HEIGHT / 2.0;

double b = WIDTH / 2.0;

double y = (b / a) * sqrt (a * a - x * x);

return y;

}

// Integration function - modified we are passing directly a and b from ellipse equation

double trapezoidal_integral (DFD f ,double a, double b, int n)

{

double x, delta, sum=0.0;

int i=0;

delta = (b-a)/ n;

// integration logic

sum = (function(a) + function(b))/2;

for (i=1, x = a + delta; i < n; i++, x += delta)

sum += function(x);

return sum * delta;

}

int main ()

{

printf ("Enter Width of the tank (in meters):\n");

scanf ("%lf",&WIDTH);

  

printf ("Enter Height of the tank (in meters):\n");

scanf ("%lf",&HEIGHT);

  

printf ("Enter Length of the tank(in meters):\n");

scanf ("%lf",&LENGTH);

  

printf ("Enter specific depth on measuring stick (in centimeters):\n");

scanf ("%lf",&DEPTH);

double h = DEPTH / 100.0;

  

double area = 2.0 * trapezoidal_integral (&function, HEIGHT / 2 - h, HEIGHT / 2, 100);

  

// volume is croos section area times lenth of tank

  

double volume = area * LENGTH;

printf ("Depth %f cm: Volume %.6lf cubic metres\n",DEPTH, volume);

return 0;

}

SCREENSHOT FOR CODE :

OUTPUT :

Add a comment
Know the answer?
Add Answer to:
Maybe it’s easier to imagine the tank on its side so that the depth gauge is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The Depth Gauge Problem Liquids are often stored in elliptical storage tanks as shown below. To...

    The Depth Gauge Problem Liquids are often stored in elliptical storage tanks as shown below. To measure the volume of liquid in the tank, a depth gauge (measuring stick) can be used. It is inserted into an opening at the top and the level of liquid on the gauge can be used to determine the amount of liquid in the tank. The tank has width w, height h and length len (all in meters). In the example output shown below,...

  • I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the...

    I wrote a program which computes the area and perimeter of a square, circle, or rectangle. As you will see in my main function, there is a for loop in which the user is supposed to be able repeat the program until they enter "q" to quit. However, my program runs through one time, the prompt appears again, but then it terminates before the user is allowed to respond to the prompt again. I'm not able to debug why this...

  • please show work 7. Find the vertex of the following function 10. A high school baseball...

    please show work 7. Find the vertex of the following function 10. A high school baseball player throws a ball straight up into the air for his math class. The height h at a certain time t can be modeled by the following function At what time will the ball hit the ground? B) (-2.-17) k(t)-16t +96t +6 o) (2,-17) a)t--0.061 seconds b) 4.512 seconds clt-5323 seconds d)?-6.062 seconds B. Find the vertex of the folowing graph: (1 -4) 9....

  • 27S 140-1 November 20, 2019 all work in the examination book. A block of mass 1.80...

    27S 140-1 November 20, 2019 all work in the examination book. A block of mass 1.80 kg is suspended from an ideal spring with force constant k = 0.200 N/m. The mass is pushed 15.0 cm below its equilibrium position and then given an initial speed of 0.300 m/s directed downward (watch signs). a. What is the period of the resulting SHM of the block? Show work. (15 points) b. Taking the upward direction as a positive y-axis, the resulting...

  • 13. Integrate: a. j«x+278)dx 0 b. (dx х c. dx 9+ x d . xdx? +2...

    13. Integrate: a. j«x+278)dx 0 b. (dx х c. dx 9+ x d . xdx? +2 dx 2x+1 хр '(x’+x+3) f. I sin (2x) dx g. cos (3x) dx h. ſ(cos(2x)+ + secº (x))dx i. [V2x+1 dx j. S x(x² + 1) dx k. | xe m. [sec? (10x) dx 16 n. .si dx 1+x 0. 16x 1 + x dx 5 P. STA dx 9. [sec xV1 + tan x dx 14. Given f(x)=5e* - 4 and f(0) =...

  • summarizr the followung info and write them in your own words and break them into different...

    summarizr the followung info and write them in your own words and break them into different key points.   6.5 Metering Chamber: 6.5.1 The minimum size of the metering box is governed by the metering area required to obtain a representative test area for the specimen (see 7.2) and for maintenance of reasonable test accuracy. For example, for specimens incorporating air spaces or stud spaces, the metering area shall span an integral number of spaces (see 5.5). The depth of...

  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT