.

closed account (z1AqoG1T)
...
Last edited on
What, exactly, do you need help with? Is it with expressing the algorithm in C++? Is it with the iteration over values? Is it with formatting the output as a table? Is it with the input validation? Is it with something else?

We cannot read your mind. Simply copying and pasting a homework question is the least helpful way of asking for help.
closed account (z1AqoG1T)
All of those, really, I’d like to know how to do the entire problem and code so that in the future, I’d have the knowledge on how to do problems like these.

If you could provide the code and explanation, that would be amazing. :)
So basically, not only do you want people to do your entire homework for you, for free, you'd also like them to give you a free tutorial so that you can bluff your teacher into thinking you actually knew how to do it yourself?
closed account (z1AqoG1T)
Sorry for taking up your time, I’ll just read ebooks and watch videos regarding the matter. :)
Hello Imafool,
sorry for the delayed response, but even it's urgent as hell, if you tug the herbage with ASAP it will not grow faster.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;

//-----------------------------------------------------
double fun(double x)
{
    return (((3*x*x-2)*x)*x+1)*x;
}
//=====================================================
int main()
{
    double a, b, c;
    unsigned char r;
    
    for (;;)        // do forever
    {
        cout << "Enter a and b (separated by blank, next hit Return or Enter): ";
        cin >> a >> b;

        do              // the do-while loop as requested
        {
            c = a;
            a = b;
            b = c;
        } while (a > b);
        
        for (; a<=b+.04; a+=.2)     // no idea yet how to apply numeric fuzz
            cout << "\nx = " << a << ", y = " << fun(a);
        
        cout << "\n\n Again? (y/n) ";
        cin >> r;
        if (r == 'N' || r == 'n')
            break;
        cout << "\n\n";
    }
}

Enter a and b (separated by blank, next hit Return or Enter): 2 3

x = 2, y = 82
x = 2.2, y = 135.513
x = 2.4, y = 213.631
x = 2.6, y = 323.889
x = 2.8, y = 475.207

 Again? (y/n) y


Enter a and b (separated by blank, next hit Return or Enter): 1 -1

x = -1, y = -2
x = -0.8, y = -0.75904
x = -0.6, y = -0.40128
x = -0.4, y = -0.30272
x = -0.2, y = -0.18496
x = -5.55112e-17, y = -5.55112e-17
x = 0.2, y = 0.18496
x = 0.4, y = 0.30272
x = 0.6, y = 0.40128
x = 0.8, y = 0.75904
x = 1, y = 2

 Again? (y/n) n
 
Exit code: 0 (normal program termination)

In case you still have some questions feel free to wade through the tutorials:
http://www.cplusplus.com/doc/

Edit: eliminated an unused variable
Edit: for lack of numeric fuzz (as in REXX) use makeshift loop end a<=b+0.04
Last edited on
Bye-bye! :)
Wow, you give a lazy scrounger everything they want, and then they bugger off and delete their question. Who on earth could have predicted that would happen?
Last edited on
Who on earth could have predicted that would happen?
Well, I did not expect it, but it is not unusual on this forum. And, frankly, I don't mind because being myself a novice in C++ I may take such tasks as an exercise. (And weather was not for gardening.)
Topic archived. No new replies allowed.