-4x3 - 12x2 + x + 15
y = -------
(2x2 + 1)1/2 + 7 * | x - 2.5 |
| | means absolute value; (...)1/2 means square root
You should use library functions for square root and absolute value.
1. The program should start by printing a message giving your name and saying this is the output of your first program.
2. Then your program should evaluate the formula shown above, starting with x = 4, going up by 0.5 each time until it reaches 3.0. Therefore, your program will use these values for x: 4, 3.5, ..., 0.5, 0, 0.5, 1, 1.5, 2.0, 2.5, 3.0.
For each x value, the program should compute the corresponding y value. It should print these values together with explanations of what the values represent. For example, it could print the string "X = ", then the value of x, the string "Y = ", the value of y, and a message. (It is also possible to use column headings and have your numbers underneath the headings.)
e your question here.
Well, I'd consider there are two main tasks here:
a) make use of a loop in order to step through the required values of x
b) translate the formula for y into suitable c++ code
You might address each of these as separate sub-topics during the development process. For example you might initially try to get the program working with a simplified formula such as y = x, when that is done, change the formula to the actual required one.
Thanks I actually got all that and converted the equation into C++. I am just lost about how the body should go. Btw Chervil I dint know this was a loop. How would a loop be set.
Well, you would need to set an initial value of x. After each pass through the loop, increase the value of x by 0.5. Test that x is within the required range before executing the body of the loop.
You could do that using either a for-loop or a while-loop, whichever you feel most comfortable with using.
The original question looks a bit odd. I misread it and assumed it meant x starting from -4.0, but that isn't what it says. Is that a mistake?