Tuesday, June 24, 2014

WE DID IT!!!

Today my partner, Jordan, and I wrote out first program for Lab #1.

The assignment given to us by Dan the Man (a.k.a. the fleet-footed horse) was to find the minimum, maximum, and mean value of a set of data. The set of data was a file that contained randomly generated numbers.

The first thing we had to do was open the file and tell the program to read it line by line. While it's reading each line, it is comparing each number to three predetermined variables : "number", "minimum", and "maximum" which were all set equal to zero. We used an if-loop as well as an else if-loop within a while loop. Basically, as the program is reading the file line by line, it stores each value into either the variable "minimum" or the variable "maximum" depending on whether or not it is greater or less than "number". We also made a variable "total" which serves as a counter for the total amount of numbers in the list. This value was used to find the mean/average value of all the numbers once they were added together.

The last thing we did was create a file with all the results. We used the "outputfile" command to create a vim file with each answer labeled.

Displaying photo.JPG

No comments:

Post a Comment