-------------------------------- Start Of Program -------------------------------- Enter the number which corresponds with one of the following functions: 0 --> f(x) = x^2 1 --> f(x) = x^3 2 --> f(x) = sin(x) 3 --> f(x) = cos(x) 4 --> f(x) = sqrt(x) 5 --> f(x) = 2x + 3 Enter Option Here: The value which was entered for option is 1. The single-variable function which was selected from the list of such functions is f(x) = x^3. -------------------------------- Enter a value to store in double-type variable a (which represents the left end of the x-axis interval): The value which was entered for a is 0. Enter a value to store in double-type variable b (which represents the right end of the x-axis interval): The value which was entered for b is 10. Enter a value to store in int-type variable n (which represents the number of equally-sized partitions to divide x-axis interval [a,b] into): The value which was entered for n is 10. The x-axis interval which was selected to partition is [0,10]. The selected number of equally-sized partitions to divide that interval into is 10. -------------------------------- Enter the number which corresponds with one of the following rectangle construction methods: 0 --> "left" 1 --> "right" 2 --> "midpoint" Enter Option Here: The value which was entered for option is 0. The rectangle construction method which was selected from the list of such methods is "left" (i.e. using the left end-point of each of the n partitions of [a,b] to set the height of each of the n rectangles). -------------------------------- dx = (b - a) / n = (10 - 0) / 10 = 1. // the length of each of the n equally-sized partitions of x-axis interval, [a,b] ~~~~~~~~~~~~~~ i = 0. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 0 * 1 = 0. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 0 * 1 = 0. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 0. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 1. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 1 * 1 = 1. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 1 * 1 = 1. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 1. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 2. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 2 * 1 = 2. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 8 * 1 = 8. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 9. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 3. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 3 * 1 = 3. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 27 * 1 = 27. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 36. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 4. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 4 * 1 = 4. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 64 * 1 = 64. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 100. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 5. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 5 * 1 = 5. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 125 * 1 = 125. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 225. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 6. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 6 * 1 = 6. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 216 * 1 = 216. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 441. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 7. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 7 * 1 = 7. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 343 * 1 = 343. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 784. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 8. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 8 * 1 = 8. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 512 * 1 = 512. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 1296. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ i = 9. // current iteration of the for loop (of 10 iterations) x = a + i * dx = 0 + 9 * 1 = 9. // the left end-point of the ith partition of [a,b]. rectangle_area_x = func(x) * dx = 729 * 1 = 729. // area of the ith rectangle sum += rectangle_x; // Add rectangle_x to sum and store the result in sum (in the C++ program). sum = 2025. // the current value stored in the variable named sum ~~~~~~~~~~~~~~ -------------------------------- End Of Program --------------------------------