Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Overview: Our Fortran 95 project will be to get a file name from the user, read x and y data from file, display the data

Overview: Our Fortran 95 project will be to get a file name from the user, read x and y data from file, display the data at the console, allow the user to remove points from the data, then find the best-fit slope and intercept and send them to the console. In more detail, the project program you write will do the following:

Prompt the user for a file name, which will be stored in a string variable. Use the ADVANCE="no" in the write statement for the prompt to get the prompt and the user's response on the same line.

Read the x and y data from the file and store it in two dynamic, double-precision real arrays. This will require counting the lines in the file to see how many data lines there are and then allocating 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:

o 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.

o 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.*

o 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 up the loop with no removal working, just to get it to print properly and get the user's input. Then, get it to 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 1 2 3 4 5 
x value 0.2304 5.2995 
y value 40.2611 35.5563 30.1252 24.6106 19.8167 

10.3687 15.4378 20.5069 to delete or 0 to keep this data: 2

Choose a The following 4 data points were read from xydata.txt

data point 1 2 3 4 

x value 0.2304 10.3687 15.4378 20.5069 
y value 40.2611 30.1252 24.6106 19.8167 

Choose a point to delete or 0 to keep this data: 0

We find the equation of the line to be y =-1.014*x + 40.504

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Climate And Environmental Database Systems

Authors: Michael Lautenschlager ,Manfred Reinke

1st Edition

1461368332, 978-1461368335

More Books

Students also viewed these Databases questions

Question

- 3.5 HW Score: 12.5%, 1 of 8 points Answered: 1 week ago

Answered: 1 week ago