Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to write a program to calculate the area under a curve : f(x) = 5x3 + 7x2 3x + 4 for a

You need to write a program to calculate the area under a curve

: f(x) = 5x3 + 7x2 3x + 4

for a <= x <= b where a and b are greater than or equal to 0.

First, use cin to input the values of a and b which are defined as double. Check whether a and b are larger than 0, and whether a is smaller than or equal to b. If NOT, display an error message and exit. If YES, your program approximates the area under the curve between a and b by partitioning the area into small segments where each segment has width w.

For each area calculation, your program should calculate areas for w, w/2, w/4, , starting with w=(b-a)/10. Your program should keep calculating more accurate areas until the difference between the last two of your calculations is less than .0001. Then the program should display the last area value calculated.

See pseudo code below.

Example Output:

Example 1: Enter value a: 2 Enter value b: 7 Result is 3715.42

Example 2: Enter value a: 5.3 Enter value b: 8.2 Result is 5557.23

Example 3: Enter value a: 2.6 Enter value b: -7.9 Invalid data, either a or b is < 0

Example 4: Enter value a: 6 Enter value b: 3.9 Invalid data, a > b

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

Students also viewed these Databases questions

Question

3. Identify cultural universals in nonverbal communication.

Answered: 1 week ago

Question

2. Discuss the types of messages that are communicated nonverbally.

Answered: 1 week ago