Output doubles help

Hello I have finished coding an assignment and I am just having a frustrating problem getting my double whole values to be displayed as int values.
For example:

I have to print the values in a table format of a equation x, y
so say I had the range -1 to 1 my table, with 5 points would be
x \ y
-1 2.122 (These (Y) don't matter as they are always double values)
-.5 3.022
0 4.043
.5 5.342
1 6.140

My problem is that for my x values I get
x \ y
-1.0 2.122
-.5 3.022
-0.0 4.043
.5 5.342
1.0 6.140

The int values still display as doubles, and the 0 is even displayed as negative 0.

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
  #include <iostream>
#include <cmath>
#include <iomanip>

#define POINTS 21

using namespace std;

int main()
{
    double xMin, y, xMax, x;
    double xInc;
    char fluff;
    double midPoint = 10;
    const double PI = 3.1416;
    double mx, mn, mean, mode;
    double dataPoints[POINTS];
    double dataPointsNew[POINTS];

    cout << "Enter a x-min and x-max value:    (ex: 12.5, 134)" << endl;
    cin >> xMin >> fluff  >> xMax;
    cout << endl;

    xInc = (fabs(xMin) + fabs(xMax)) / (POINTS - 1);   //Finding the increments x will increase by based of max and min and total points
    x = xMin;    //Initial start of x will be the xMin value

    cout << fixed << setw(8) << "X-Value" << setw(3) << "| " << setw(8) << "Y-Value" << endl; //begin the table with heading and 1st line

    double halfOne = ((1.0 / 32.0) * 2.0 * PI * sin((6.036 * x)));
    double halfTwo = ((1.0 / 64.0) * PI * cos((24.44 * x)));

    dataPoints[0] = halfOne + halfTwo;

    cout << fixed << setprecision(1) << setw(8) << x << setw(3) << " " << setw(8) << setprecision(3) << dataPoints[0] << endl;

    for(int i = 1; i < POINTS; i++)
    {
        x += xInc;
        y = (((1.0 / 32.0) * 2.0 * PI * sin((6.036 * x))) + ((1.0 / 64.0) * PI * cos((24.44 * x))));
        dataPoints[i] = y;

        if(x < 0 || x > 0)
        {
            cout << fixed << setprecision(1) << setw(8) << x << setw(3) << "  " << setw(8) << setprecision(3) << dataPoints[i] << endl;
        }

        else
        {
            cout << fixed << setprecision(1) << setw(8) << fabs(x) << setw(3) << "  " << setw(8) << setprecision(3) << dataPoints[i] << endl;
        }
    }
Topic archived. No new replies allowed.