help fortran

profileBo_Ali
p4.pdf

The program is due Monday, April 27. +10 points bonus if the program is submitted Wednes day, April 22. +20 points bonus if the program is submitted Monday , April 20.

ENGR 1120 FORTRAN 90: Graded Program 4 Write a program to read in up to 100 positive real values from a data file that everyone will name “p4data.dat” < 4A > , output them in ascending order < 10A >, calculate and print the average < 10B >, the median < 10C >, the variance < 10D >, and the standard deviation < 4E >. The average, sorting, variance, median, and prin ting should each be carried out in separate subroutines <20F>. The program must allow processing of multiple sets of data during one execution <10G>. An entry of -1. will be used as a sentinel signal f or the end of each data set in the data file. The program will have the same format as indicated by the example output below <12H>. Sample Data: 60.

110. 80. 50.

-1. {The –1. is a “trailer signal”, used only to establ ish the end of a data set} EXAMPLE OUTPUT: ------------------------------ (30 dashes) ORIGINAL DATA: 60.00

110.00 80.00 50.00

Average = 75.00 Median = 70.00 Variance = 700.00 Standard Deviation = 26.46 VALUES SORTED: 50.00 60.00 80.00 110.00 ------------------------------ (30 dashes) If more than one page is printed, staple the first output followed by the second output. Proper presentation <10K> is required.

OFFICIAL DATA FILE TO BE USED FOR PROGRAM 4 (Also p osted in iLearn in Notepad):

9. 6. 28. 8. 53. 10. 62. -1. 100. 2. 25. 93. 4. 48. 14. 32. 69. 58. 58. 110. 87. 69. 19. 80. -1. SUGGESTED ORDER OF DEVELOPMENT: 1. Initially set up the framework of the program to read in only 1 set of data (USE SAMPLE

DATA ), load it into an array called x, and print x to the screen. 2. Modify the program to use a subroutine to calculate and print the average. 3. Modify the program to use a subroutine to calculate and print the variance and standard

deviation. 4. Modify the program to use a subroutine to sort and print out the array in ascending order. 5. Modify the program to use a subroutine to calculate the median. 6. Modify the data file to only include the values listed above under the “OFFICIAL DATA FILE”

heading.

7. Modify the program to process multiple sets of data. 8. Add proper formatting. (Due by 8:00AM April 27)

9. +10 bonus: add documentation as outlined in “Form and Documentation for Programs” and

“Documenting Subroutines” posted in iLearn.

Variance = 1

1 2)(

∑ =

n

n

i x

i x

,

where x is the mean (average) of the sample data.

EXAMPLE: Given the data: 60 , 110 , 80 , and 50 n = 4

The average is 75.0 The variance is therefore: {(60-75)2 + (110-75)2 +(80-75)2 +(50-75)2 } / 3

= 700. The Standard Deviation is the square root of the variance = 26.46

Definition of Median The median is defined as “a value in an ordered set of values, below and above which there are an equal number of values.” This means the median of a group of numbers is identified differently, depending on whether the quantity of numbers is odd or even. EXAMPLE 1: For the five numbers below, which are listed in ascending order, the median is simply the middle number—in this case 5.5 3.0 4.5 5.5 6.4 6.6 EXAMPLE 2: For the four numbers below, which are listed in ascending order, the median is the average of the two middle numbers—in this case 4.5 and 5.5 So the median here is 5.0

3.0 4.5 5.5 6.4