A line of best fit is a straight line that best approximates a collection ofndata points. In this exercise, we will assume that each point in the collection has anxcoordinate and aycoordinate. The symbolsxandyare used to represent the averagexvalue in the collection and the averageyvalue in the collection respectively. The line of best fit is represented by the equationy=mx+bwheremandbare calculated using the following formulas:
Write a program that reads a collection of points from the user. The user will enter the x part of the first coordinate on its own line, followed by the y part of the first coordinate on its own line. Allow the user to continue entering coordinates, with thexandyparts each entered on their own line, until your program reads a blank line for thexcoordinate. Display the formula for the line of best fit in the formy=mx+bby replacingmandbwith the values you calculated using the preceding formulas. For example, if the user inputs the coordinates(1,1),(2,2.1)and(3,2.9)then your program should displayy= 0.95x+ 0.1.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here