Question

In: Computer Science

Compute the area under y = √x between x = a and x = b where...

Compute the area under y = √x between x = a and x = b where a and b are user specified values obtained via cin. Account for invalid user input cases of a < 0 and a > b. For each case of invalid input, immediately output to the user what the error was. Allow the user a total of three chances to enter valid input for each input request. If the user enters incorrect input three times in a row for an input request, display a different error and exit the program.

Solutions

Expert Solution

#include
#include // std::setprecision
#include
#include
#include // std::string, std::stod
#include
using namespace std;

int main()
{
float a,b;
for(int i=0;i<3;i++)
{
cout<<"Enter a and b"< cin>>a>>b;
if(a>=0&&a<=b)
break;
else
{
if(i==2)
{
cout<<"You have exhausted all 3 chances"< return 1;
}

cout<<"Invalid values entered"< }

}
float b3=b*b*b,a3=a*a*a;
float value=(float)(sqrt((b3))-sqrt(a3));
cout<<"The area computed is equal to : "<<(float)((float)2/(float)3)*(float)value<

}


Related Solutions

1. Find the area between the curves y = x2 and y = x + 2....
1. Find the area between the curves y = x2 and y = x + 2. Round your answer to one decimal place. 2. Find the area under the curve defined by the following data points: x 1 4 7 10 13 16 19 22 25 y 4.2 4.6 4.8 6.2 6.8 7.8 9.1 8.8 9.4 Round your answer to 2 decimal places. I appreciate your help :)
The three parts of this problem concern the area under the graph of y=f(x)=1/x on the...
The three parts of this problem concern the area under the graph of y=f(x)=1/x on the interval (.5,4). (A) Estimate this area using L6. That is, use 6 equal width rectangles over the interval (.5,4), the height of each rectangle determined by the left endpoint of each subinterval. (B) Estimate this area using R6. That is, use 6 equal width rectangles over the interval (.5,4) with the height of each rectangle determined by the right endpoint of each subinterval. (C)...
With the area between the graphs: x+y=14 x+6=y^2 Find the area two different ways First way:...
With the area between the graphs: x+y=14 x+6=y^2 Find the area two different ways First way: [a,b]integral(f(x))dx + [b,c]integral(g(x))dx = whats is a,b,c, f(x), and g(x): Second way: [a, b]integral(h(y))dy what is a, b, and h(y)
Find the area enclosed between the x-axis and the curve y=x(x-1)(x+2)
Find the area enclosed between the x-axis and the curve y=x(x-1)(x+2)
using matlab, compute and plot y [n] = x [n]* h [n], where a. x [n]...
using matlab, compute and plot y [n] = x [n]* h [n], where a. x [n] = h [n] = a^n (0 <=n <=40) & a = 0.5 b. x [n] = cos [n]; h [n] = u [n]; n = 0:4:360 c. x [n] = sin [n] ; h [n] = a^n; n:4:360; a = 0.9
Describe a probability distribution. Explain the x-axis, y-axis, and area under the distribution.
Describe a probability distribution. Explain the x-axis, y-axis, and area under the distribution.
Compute the correlation between X and the transformed Y values. Distance jumped in inches (X) Distance...
Compute the correlation between X and the transformed Y values. Distance jumped in inches (X) Distance of discus throw in inches (Y) 3 12 1 36 4 60 1 12 3 48 5 12 1 24
For the X,Y data below, compute:
For the X,Y data below, compute: X Y 2 5 4 6 4 7 5 11 6 12 (a) the correlation coefficient and determine if it is significantly different from zero. (b) find the regression line. c) interpret the coefficient of the regression line d) at 5% test if the Y is related to X e) find the coefficient of determination and interpret this coefficient. f) predict the value of average Y if the average of X is13 g) at...
Approximate the area under the curve y=x^3+4 from x=2 to x=5 using a left sum with...
Approximate the area under the curve y=x^3+4 from x=2 to x=5 using a left sum with 6 subdivisions. The area is approximately
Consider the parabolas y=x^2 and y=a(x-b)^2+c, where a,b,c are all real numbers (a) Derive an equation...
Consider the parabolas y=x^2 and y=a(x-b)^2+c, where a,b,c are all real numbers (a) Derive an equation for a line tangent to both of these parabolas (show all steps with a proof, assuming that such a line exists) (b) Assume that the doubly-tangent line has an equation y+Ax+B. Find an example of values of a,b,c (other than the ones given here) such that A,B ∈ Z
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT