ME021 Engineering Computing Spring 2018
The arrays. You may assume there will always be two header lines, but there could be any number of data lines. Set up a loop where: The data is shown on the console with a line number for each line. For larger data sets, this may cause the console to scroll, which is fine. The user is asked if there is a data point to be removed. If there is, then remove it from the arrays. This may require allocating temporary arrays and allocating the data arrays again. You will need to use the deallocate function before allocating an array that has already been allocated. Choose how to set up the prompts for this to make sense to the user. If the user chose not to remove a data point, exit the loop. Compute the averages and the best-fit slope and intercept, per the relations above. Print the resulting equation for the best-fit line in a tidy format that uses engineering notation.
* Plan on spending some time on this data point removal requirement. It will require some thinking about how the loop should run, when it should check to leave the loop, and so on. It may be helpful to initially set remove the chosen data point, which there are several ways to do.
Your program should run for any length data file, without assuming a maximum length anywhere. Three data files (xydata1.txt, xydata2.txt, and xydata3.txt) are provided on CatCourses for testing, and your TA may choose to use others as well.
Sample Run
To help visualize what the program will look like when running, a sample run is shown below. The sample data file used xydata.txt is also available on CatCourses.
Enter the data file name: xydata.txt
The following 5 data points were read from xydata.txt:
Data point x value y value
0.2304 40.2611
5.2995 35.5563
16.3687 30.1252
15.4378 24.6166
20.5669 19.8167
Choose a point to delete or 'e' to keep this data: 2
The following 4 data points were read from xydata.txt:
Data point x value y value
0.2304 40.2611
10.3687 30.1252
15.4378 24.6106
20.5669 19.8167
Choose a point to delete or 'e' to keep this data: c
We find the equation of the line to be:
y = -1.014*x + 48.584