Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are two les for the problem: 1. Neville’s Data This is the data points to

ID: 3733558 • Letter: T

Question

There are two les for the problem:
1. Neville’s Data
This is the data points to be used to construct the interpolation function. The le contains two rows of numbers, for example:
x g

0.1 1.3

0.8 9.2

0.9 3.5 ...

There is a sample code on how to read in the data into two C arrays, xData and yData.
2. The second le is a number of points that you want to nd the value of the interpolated function at that point. Read those x values into your program and have the program print out two columns,
¿newXDate? newYvalue

0.25 0.80

I would like the computed values to be written to an output le called Nevilles. The output le should contain two rows:

x1 f(x1)

x2 f(x2)

... ...

¿xi? ¿f(xi)?

where each f(xi) is the interpolated value at the point xi.

File:

Neville_Data

0.000000 0.000000
0.050000 0.000122
0.100000 0.000946
0.150000 0.003096
0.200000 0.007094
0.250000 0.013360
0.300000 0.022198
0.350000 0.033799
0.400000 0.048230
0.450000 0.065430
0.500000 0.085210
0.550000 0.107240
0.600000 0.131043
0.650000 0.155984
0.700000 0.181265
0.750000 0.205916
0.800000 0.228802
0.850000 0.248636
0.900000 0.264022
0.950000 0.273522
1.000000 0.275758
1.050000 0.269573
1.100000 0.254214
1.150000 0.229572
1.200000 0.196414
1.250000 0.156594
1.300000 0.113150
1.350000 0.070221
1.400000 0.032681
1.450000 0.005418
1.500000 -0.007728
1.550000 -0.005268
1.600000 0.010706
1.650000 0.033836
1.700000 0.053966
1.750000 0.059287
1.800000 0.040278
1.850000 -0.005291
1.900000 -0.068081
1.950000 -0.126383
2.000000 -0.151463
2.050000 -0.119780
2.100000 -0.028805
2.150000 0.091783
2.200000 0.184181
2.250000 0.188230
2.300000 0.082032
2.350000 -0.086802
2.400000 -0.211296
2.450000 -0.190617
2.500000 -0.019021
2.550000 0.177790
2.600000 0.223289
2.650000 0.055684
2.700000 -0.173494
2.750000 -0.217329
2.800000 -0.009094
2.850000 0.211004
2.900000 0.154203
2.950000 -0.115401
3.000000 -0.211261
3.050000 0.021266
3.100000 0.211754
3.150000 0.032989
3.200000 -0.196750
3.250000 -0.044512
3.300000 0.186185
3.350000 0.018976
3.400000 -0.176515
3.450000 0.037532
3.500000 0.145563
3.550000 -0.106771
3.600000 -0.066854
3.650000 0.140506
3.700000 -0.050393
3.750000 -0.078409
3.800000 0.117642
3.850000 -0.054847
3.900000 -0.037469
3.950000 0.089391
4.000000 -0.081386
4.050000 0.035796
4.100000 0.014269
4.150000 -0.047238
4.200000 0.058009
4.250000 -0.052179
4.300000 0.038437
4.350000 -0.023776
4.400000 0.012028
4.450000 -0.004370
4.500000 0.000418
4.550000 0.000854
4.600000 -0.000600
4.650000 -0.000083
4.700000 0.000177
4.750000 0.001225
4.800000 -0.004717
4.850000 0.010126
4.900000 -0.015887
4.950000 0.018702

Explanation / Answer

1.

class record {

private:

int x, g;

  

public:

record() { x = g = 0;

};

set( int x, int g ) {

x = xdata; g = ydata;

  

};

~record() { };

};

int main(){

record arrayOfRecords[100];

string filename = "A.dat";

string line;

ifstream inFile;

int i = 0;

int xdata, ydata;

  

inFile.open(filename.c_str());

if (inFile.fail())

{

cout << " The file was not successfully opened"

<< " Please check that the file currently exists."

<< endl;

exit(1);

}

while( !inFile.eof() ) {

inFile >> xdata >> ydata;

arrayOfRecords[i].set( xdata,ydata );

i++;

}

}