Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help. The Program is C++, thanks! The force (Y) generated by a spring is a function of the springs displacement(X). The plot below shows

Please help. The Program is C++, thanks!

The force (Y) generated by a spring is a function of the springs displacement(X). The plot below shows the relationship between displacement and force. The greater the displacement, the greater the force generated. By inspection, the relationship appears to be linear.

Create a linear regression program that outputs the slope and y-intercept of the best fit line for a set of ordered pairs. Corresponding elements in the displacement and force arrays form ordered pairs. The program must have five user defined functions as outlined below.

Populate two arrays(X[],Y[]) using data in lin_reg.txt, you must use file input.

Multiply two arrays

Square an array

Calculate the slope of the best fit line

Calculate the y-intercept of the best fit line

The force (Y) and displacement (X) data is in the file lin_reg.txt. You can not modify lin_reg.txt, you must use it as is.

The lin_reg.txt file contains these values in this format:

X(m) -.0015 -.0039 -.0058 -.0079 -.0101 -.0119 -.0143 -.0157 -.0179 -.0198 Y(N) 17 42 54 84 105 121 159 170 199 216

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

Managerial Accounting Tools For Business Decision Making

Authors: Jerry J. Weygandt, Paul D. Kimmel, Ibrahim M. Aly, Donald E. Kieso

6th Canadian Edition

1119731828, 9781119731825

More Books

Students also viewed these Accounting questions

Question

What is the purpose of the application form?

Answered: 1 week ago

Question

What is the general purpose of preliminary screening?

Answered: 1 week ago