10-28-2011, 03:25 PM
Question:
Write a program that computes the average and standard deviation of the text floating point numbers in a file. Use the following formulas for the average and the standard deviation of N values. The formulas compute the sum, the sum of squares, the average, the average square, the variance, and finally, the standard deviation.
[FONT="]sum = x1 + x2 + x3 + ... + xN-1 + xN [/FONT]
[FONT="] [/FONT]
[FONT="]sumSQ = x12 + x22 + x32 + ... + xN-12 + xN2 [/FONT]
[FONT="] [/FONT]
[FONT="]avg = sum/N[/FONT]
[FONT="] [/FONT]
[FONT="]avgSQ = sumSQ/N[/FONT]
[FONT="] [/FONT]
[FONT="]var = avgSQ - avg2[/FONT]
[FONT="] [/FONT]
[FONT="]sd = var(1/2)[/FONT]
The input file will contain any number text floating point numbers, similar to the following:
[FONT="]10.5[/FONT]
[FONT="]12.9[/FONT]
[FONT="]9.67[/FONT]
[FONT="]12.05[/FONT]
[FONT="]8.23[/FONT]
[FONT="]10.08[/FONT]
[FONT="]10.23[/FONT]
[FONT="]7.7[/FONT]
[FONT="]10.4[/FONT]
[FONT="]11.34[/FONT]
Numbers could be several, or none per line, and negative numbers are perfectly OK.
Note: All the source code should be written manually. Your code must justify enough for 15 marks.
Write a program that computes the average and standard deviation of the text floating point numbers in a file. Use the following formulas for the average and the standard deviation of N values. The formulas compute the sum, the sum of squares, the average, the average square, the variance, and finally, the standard deviation.
[FONT="]sum = x1 + x2 + x3 + ... + xN-1 + xN [/FONT]
[FONT="] [/FONT]
[FONT="]sumSQ = x12 + x22 + x32 + ... + xN-12 + xN2 [/FONT]
[FONT="] [/FONT]
[FONT="]avg = sum/N[/FONT]
[FONT="] [/FONT]
[FONT="]avgSQ = sumSQ/N[/FONT]
[FONT="] [/FONT]
[FONT="]var = avgSQ - avg2[/FONT]
[FONT="] [/FONT]
[FONT="]sd = var(1/2)[/FONT]
The input file will contain any number text floating point numbers, similar to the following:
[FONT="]10.5[/FONT]
[FONT="]12.9[/FONT]
[FONT="]9.67[/FONT]
[FONT="]12.05[/FONT]
[FONT="]8.23[/FONT]
[FONT="]10.08[/FONT]
[FONT="]10.23[/FONT]
[FONT="]7.7[/FONT]
[FONT="]10.4[/FONT]
[FONT="]11.34[/FONT]
Numbers could be several, or none per line, and negative numbers are perfectly OK.
Note: All the source code should be written manually. Your code must justify enough for 15 marks.

(((((((((((said