ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 9 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 26 Apr 2017 My Price 9.00

C++ programming

C++ programming

Goals: Developing problem-solving skills, declaring variables, reading data from a file, using loops, and using arrays and functions.

Problem: Many engineering and scientific relationships can be manipulated to a format of a straight line, y = mx + b, where m is the slope of the line and b is the y intercept. However, because most measurements have some inherent error, the formula for the line may not be obvious. Therefore, linear regression may be used to determine the best fit of a line to the measured data. Linear regression uses the following two equations for calculations of slope and y-intercept.

(note you will need to skip over the first line in the file, do not change the file!)

 

Proj4Linear.txt

x y 0 4.835 0.04 4.92 0.1 5.143 0.12 5.227 0.22 5.591 0.24 5.638 0.26 5.704 0.32 5.906 0.34 6.023 0.36 6.026 0.42 6.262 0.44 6.331 0.46 6.399 0.52 6.614 0.58 6.86 0.6 6.872 0.62 6.98 0.64 7.025 0.7 7.3 0.72 7.323 0.8 7.631 0.82 7.654 0.84 7.77 0.9 7.91 1 8.256 1.08 8.556 1.1 8.615 1.12 8.715 1.14 8.777 1.16 8.873 1.22 9.106 1.24 9.119 1.34 9.476 1.48 9.958 1.5 10.032 1.52 10.083 1.54 10.171 1.58 10.337 1.6 10.366 1.62 10.468 1.7 10.751 1.72 10.8 1.74 10.845 1.76 10.955 1.8 11.051 1.88 11.361 1.9 11.433 1.92 11.475 1.98 11.768 2.04 11.973 2.2 12.536 2.22 12.57 2.24 12.665 2.3 12.891 2.32 12.917 2.38 13.09 2.42 13.223 2.48 13.49 2.5 13.512 2.6 13.91 2.62 13.996 2.64 14.062 2.7 14.271 2.76 14.457 2.82 14.688 2.84 14.773 2.9 14.967 2.92 15.034 2.98 15.26 3 15.34 3.18 15.915 3.22 16.034 3.28 16.305 3.3 16.339 3.32 16.4 3.38 16.66 3.4 16.655 3.42 16.763 3.44 16.877 3.5 17.045

Goals: Developing problem-solving skills, declaring variables, reading data from a file, using
loops, and using arrays and functions.
Problem: Many engineering and scientific relationships can be manipulated to a format of a
straight line, y = mx + b, where m is the slope of the line and b is the y intercept. However,
because most measurements have some inherent error, the formula for the line may not be
obvious. Therefore, linear regression may be used to determine the best fit of a line to the
measured data. Linear regression uses the following two equations for calculations of slope and
y-intercept. Σx ∗ Σy - n Σ(x * y) (Σx)2 – n Σ(x)2 Slope = Σy – slope * Σx
y-intercept = n
where n is the number of (x,y) data sets that were measured. The “goodness of fit” of this
straight line can be estimated by summing the square of the residuals. The residual is defined as
the difference between the measured y value and the calculated y value (using the calculated
slope and y-intercept) for a given x. The equation is shown below where ym is the measured “goodness of fit” = Σ(ym - yc)2 y value and yc is the calculated y value. A lower “goodness of fit” value indicates a better match
of the line to the data.
For this assignment, you write the C++ source code that uses a set of data to determine the
slope and y-intercept of the line the best fits this data. The data is stored in a file called
Proj4Linear.txt. The x-values are in the left column and the y-values are in the right column.
Then you are to determine the “goodness of fit” of this line to the data. The data may be found
in a file on ANGEL with the name linear.txt. Your program should output the calculated values
of slope and y-intercept; output the x and y values from the file; and the measured y value for x =
2.42. Your program should employ the following: ♦ a function that reads the data file and inputs the data into parallel 1-dimensional
arrays for measured x and y values. The left column should be stored in the array for
x-values and the right column should be stored in the array for y-values. The two
1dimensional arrays should be sent back to the function call in main.
♦ a function that accepts the x and y arrays and calculates the slope and y intercept
which are sent back to main.
♦ a function accepts the x and y arrays, the slope and y intercept then determines the
goodness of fit, and returns the goodness of fit to the function call.
♦ a function that searches the original x data for a specific x value and returns the index
of that x value so main can output the y value that corresponds to that x value.
.
Your main function should call the function to read the file, call the function to determine the
slope and y-intercept, output the formula of the line, call the function to determine the goodness
of fit, display the goodness of fit ask the user to input an x value for searching, and output the
corresponding y value.
Remember to include comments for the overall program specifying the purpose of the program,
input, output and processing. In addition, write comments immediately before each function
other than main which specifies the purpose of the function, input to the function (what is passed
to the function or input within the function), output form the function (what is returned from the
function or displayed by the function) and processing needed to complete the task of the
function.
Do not use pointers, vectors or any concepts beyond Chapter 8 of your text book.
Remember using material obtained by internet searches constitutes a violation of academic
integrity.

Attachments:

Answers

(11)
Status NEW Posted 26 Apr 2017 12:04 AM My Price 9.00

-----------

Attachments

file 1493168235-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)