Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include<iostream> #include<cmath> using namespace std; double f(float); int mai

ID: 3699174 • Letter: #

Question

#include<iostream>

#include<cmath>

using namespace std;

double f(float);

int main() {

//declaring the required variables

float x1;

float x2;

int n;

float h;

float x;

float area = 0;

cout<< "The program calculates the area under a curve between two points on the x axis"<< endl;

cout << "The equation is: X^2+1.5X+2" << endl;

cout << "Please enter X min value(Positive Whole Numbers only):";

cin >> x1;

cout << "Please enter X max value(Positive Whole Numbers only):";

cin >> x2;

//Here n is the number of rectangles formed by the min and max X values

n=x2-x1;

//Calculating the width

float w=(x2-x1)/n;

//Calculating the area

for (int i = 1; i <= n; i++,x1++) {

x =(x1+(x1+1))/2;

//calculating the area of the rectangle i

area = area + (w * (f(x)));

}

//Printing the result

cout << "The area under the curve between min x" << x1 << "max is :"<< area<< " square inches" << endl;

}

//function to get the f(x) value

double f(float x) {

return pow(x, 2) + 1.5 * x + 2;

}

Ouput:

The program calculates the area under a curve between two points on the x axis
The equation is: X^2+1.5X+2
Please enter X min value(Positive Whole Numbers only):1
Please enter X max value(Positive Whole Numbers only):4
The area under the curve between min x4max is :38 square inches

PART B) Three changes are to be made to the C++ program. above that uses the Riemann sum to calculate the area under a curve

1) # of Segments: prompt the user for how many segments the x axis should be divided into. For example: if the user sets the x axis range from 3" to 8", the previous program from Part A would divide it into five, 1" segments (#1: 3" to 4"; #2: 4" to 5"; #3: 5" to 6"; #4: 6" to 7"; #5: 7" to 8"). With the Part B update, the incremental area width will need to be calculated. For example, the user inputs a min of 3, a max of 7 with 50 segmentsEach segment width will now be 1/50th of the distance between 3 and 7.

2) Range of Min Max: the user should now be able to enter negative numbers for the min and max numbers. For example: a range of -4 to 4 is now acceptable.

3) The range min and max can now be real numbers. For example -8.5 to 8.5.

This is a sample of how the program should be displayed on the console...

This program calculates the area under a curve between two points on the x axis.

The equation is: XXXXXXXX

Please Enter the min x value: -8.5

Please Enter in the max x value: 8.5

Please enter the number of Intervals (Integer only): 100

The area under the curve between ‘min x’ and ‘max x’ is: ‘total’ square inches(Note, -8.5, 8.5 and 100 are user inputs)

Explanation / Answer

#include #include using namespace std; int main() { float a, b, c, x1, x2, determinant, realPart, imaginaryPart; cout > a >> b >> c; determinant = b*b - 4*a*c; if (determinant > 0) { x1 = (-b + sqrt(determinant)) / (2*a); x2 = (-b - sqrt(determinant)) / (2*a); cout