Need a bit of help formatting my output. I'm not even sure that this can be done. The output from the following code looks like this:

********************
rval = 0.954316
tval = 9.03351
p = 0.999997
Two tailed value = 5.716140e-006

Ok is there anyway I can make the Two tailed value output look like this:
Two tailed value = 1.80 * 10^-5 (you know ^ -5 is the exponential)

``````// Simpson.h: interface for the CSimpson class.
//
//////////////////////////////////////////////////////////////////////

#ifndef CSIMPSON_H
#define CSIMPSON_H

#include "Node.h"

class CSimpson
{
public:
CSimpson();
~CSimpson();
double calcSimpson(double low, double high, double N, double W, double dof);
double calcRval(CNode *sNode, double &dof);
double norm(double val);
double tDist(double val, double dof);
double gamma(double val);

private:
double myVar;
double PI;
};

#endif

// Node.h: interface for the CNode class.
//
//////////////////////////////////////////////////////////////////////

#ifndef CNODE_H
#define CNODE_H

class CNode
{
public:
//Functions of the class CNode
CNode();
~CNode();
void newNode(CNode **beginNode, double newInt1, double  newInt2);
void displayList (CNode *beginNode);
int isEmpty (CNode *beginNode);
double calculateSD(CNode *bNode, double &B0, double &B1, double guess, double &dof);

//Varialbles of the class
double int1;
double int2;
CNode *next;

};

#endif

// Simpson.cpp: implementation of the CSimpson class.
//
//////////////////////////////////////////////////////////////////////

#include "Simpson.h"
#include <iostream>
#include <math.h>

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CSimpson::CSimpson()
{
myVar = 0.39894;
PI = 3.1415927;
}

CSimpson::~CSimpson()
{

}

double CSimpson::calcSimpson(double low, double high, double N, double W, double dof)
{

double sum = 0;
double dist = 0;
double originalLow;
int multiply = 2;

originalLow = low;

if (low < 0)
{
low = (low * (-1));
}

sum = norm(low) + norm(high);

for (int i = 1; i < (N); i++)
{
if((i % 2) == 0)
{
multiply = 2;
}
else
{
multiply = 4;
}
dist = (low + ( i * W));
sum = sum + (multiply * (norm(dist)));
}

if (originalLow < 0)
{
sum = 0.5 - (sum * (W/3));
}
else
{
sum = 0.5 + (sum * (W/3));
}
return sum;
}

double CSimpson::norm(double val)
{
double temp;

temp = exp(-(pow(val, 2) / 2));
temp = myVar * temp;

return temp;
}

double CSimpson::tDist(double val, double dof)
{
double temp = 0;

temp = pow(1 + (pow(val,2)/dof),(((dof +1)/2) * (-1)));
return temp;

}

double CSimpson::gamma(double val)
{
double temper = val;
double summer = 1;

while ((temper - 1) > 0){
if((temper - 1) == 0.5){
summer = 1.7724539 * 0.5 * summer;
}
else {
summer = (summer * (temper - 1));
}
temper = temper - 1;
}

return summer;
}

double CSimpson::calcRval(CNode *sNode, double &dof)
{
CNode *thisPtr;
thisPtr = sNode;

int n = 0;
double xSum = 0;
double ySum = 0;
double xy = 0;
double xSquare = 0;
double ySquare = 0;
double xAve = 0;
double yAve = 0;
double rVal = 0;
double var = 0;
double std = 0;
double bot = 0;

while(thisPtr != NULL)
{
n++;
xy = xy + ((thisPtr->int1) * (thisPtr->int2));
xSum = xSum + thisPtr ->int1;
ySum = ySum + thisPtr ->int2;
xSquare = xSquare + pow(thisPtr->int1, 2);
ySquare = ySquare + pow(thisPtr->int2, 2);
thisPtr = thisPtr -> next;
}

xAve = xSum / n;
yAve = ySum / n;

dof = n;
rVal = ((n * xy) - (xSum * ySum)) / (sqrt(((n * xSquare) - pow(xSum, 2)) * ((n * ySquare) - pow(ySum, 2))));

return rVal;
}

// Node.cpp: implementation of the CNode class.
//
//////////////////////////////////////////////////////////////////////

#include "math.h"
#include "string.h"
#include "Node.h"
#include <iostream>
using namespace std;

CNode::CNode()
{
}
CNode::~CNode()
{
}
void CNode::newNode (CNode **bNode, double newInt1, double newInt2)
{
CNode *newPtr;
CNode *endPtr;
CNode *thisPtr;

newPtr = new CNode;

if(newPtr)
{
newPtr->int1 = newInt1;
newPtr->int2 = newInt2;
newPtr->next = NULL;
endPtr = NULL;
thisPtr = *bNode;

while ((thisPtr != NULL))
{
endPtr = thisPtr;
thisPtr = thisPtr -> next;
}

if (endPtr == NULL)
{
newPtr -> next = *bNode;
*bNode = newPtr;
}
else
{
endPtr -> next = newPtr;
newPtr -> next = thisPtr;
}
}
else
{
cout << newInt1 << " not inserted, there was no available memory.\n";
}
}

int CNode::isEmpty (CNode *bNode)
{
if(bNode == NULL)
{
return 1;
}
else
{
return 0;
}
}

double CNode::calculateSD(CNode *bNode, double &B0, double &B1, double guess, double &dof)
{
CNode *thisPtr;
thisPtr = bNode;

int n = 0;
double x = 0;
double y = 0;
double xy = 0;
double xSquare = 0;
double xAve = 0;
double yAve = 0;
double range = 0;
long double var = 0;
long double std = 0;
long double bot = 0;

while (thisPtr != NULL)
{
n++;
xy = xy + ((thisPtr -> int1) * (thisPtr -> int2));
x = x + thisPtr -> int1;
y = y + thisPtr -> int2;
xSquare = xSquare + pow(thisPtr -> int1,2);
thisPtr = thisPtr -> next;
}

xAve = x/n;
yAve = y/n;

B1 = (xy - (n * xAve * yAve)) / (xSquare - (n * (pow(xAve, 2))));
B0 = yAve - (B1 * xAve);

thisPtr = bNode;

while(thisPtr != NULL)
{
var = var + pow((thisPtr->int2 - B0 - (B1 * thisPtr->int1)),2);
bot = bot + pow((thisPtr->int1 - xAve),2);
thisPtr= thisPtr->next;
}

var = var / (n-2);
std = sqrt(var);

cout << "\nStandard Deviation = " << std;

dof = n;
range = std * sqrt(1 + (1/n) + ((pow((guess - xAve),2)) / bot));

return range;
}

void CNode::displayList(CNode *bNode)
{
if (bNode == NULL)
{
cout << "\nList starts at address "
<< bNode << endl;
cout << "(List is empty)\n";
cout << "List end at address "
<< bNode << endl;
}
else
{
cout << "\nList starts at address "
<< bNode << endl;

while (bNode != NULL)
{
cout << "Data " << (double) bNode->int1 << ", "
<< (double) bNode->int2 << " -> ";
cout << bNode->next << endl;
bNode = bNode->next;
}

cout << "List end at address "
<< bNode << endl;
}

}

#include "math.h"
#include "string.h"
#include <iostream>
#include "Simpson.h"
#include "Node.h"
using namespace std;

int main()
{
CNode N1;
CSimpson S1;
CNode *startPtr = NULL;   //Node Pointer to start of List
double temp = 1;		  //Temporary storage for linked list data
double temp2 = 1;
double xLow = 0;
double W;
double p;
double twoTail;
double dof;
double rVal;
double tVal;
int N = 20;

cout << "Welcome to the correlation machine!!" << endl;
cout << "************************************";
cout << "\nHere is how it works please enter the Actual New and Changed LOC which";
cout << "\nwill serve as your x value, followed by the Development Hours which";
cout << "\nwill serve as your y value, when you would like conclude the list enter";
cout << "\nzero for both values!" << endl;
cin >> temp >> temp2;

while (temp != 0)
{
N1.newNode(&startPtr, temp, temp2);
cin >> temp >> temp2;
}

//Calculations
rVal = S1.calcRval(startPtr, dof);
dof = dof - 2;
tVal = (rVal * sqrt(dof)) / (sqrt(1 - pow(rVal, 2)));
W = (tVal - xLow) / N;
p = S1.calcSimpson(xLow, tVal, N, W, dof);

//Output
cout << "\nHere is your output!" << endl;
cout << "********************";
cout << "\nrval = " << rVal;
cout << "\ntval = " << tVal;
cout << "\np = " << p;
twoTail = 2 * (1 - p);
cout << "\nTwo tailed value = " << scientific << twoTail << endl;

return 0;
}``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.