-3

Please help how do i do this program?? i have only two more days before it is due :(


Write a program to read data from a large text file. Within the file, the data are arranged in two columns, separated by white space characters, and comprised of a variable number of rows of data, the last of which contains nine nines (999999999) in each column. An example data file is found on the Blackboard site. The rows of data are x and y pairs of data where x is an angle in degrees and y is a function of that angle. The angle data are spaced irregularly.
Input the data and compute a new set of x and y values at equal integer increments (0,1,2,…) of angle from 0 to 360 degrees. Compute the new y values using linear interpolation. Output new, equally spaced data to a file; include the name of the original data file within the new data file.

This is what i have so far:

#include<iostream.h>
#include<fstream.h>

int main(){
    ifstream fin("prog8.dat");
   float y[1000], x[1000]; //read the two columns
   for (int lcv = 0; lcv < 1000; lcv++)
   fin >> y[lcv]>> x[lcv];
   
   // y fucntion
   y[lcv] = y[lcv-1]+ ((y[lcv+1]-y[lcv-1])/(x[lcv+1]-x[lcv-1])*(x-x[lcv-1]))
Votes + Comments
Jsut letting you know it's rude to use the word URGENT, and many will ignore your post...
2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by abhimanipal
0

After inputting the data, should you not create a separate for loop from 0.. 360 for that increment stuff ?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.