Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##Justin Beitz
- ##Assignment 3
- unless ARGV[0].to_s == "input.txt"
- puts "Wrong input"
- end
- unless ARGV[1].to_s == "output.txt"
- puts "Wrong output"
- end
- input = ARGV[0].to_s
- output = ARGV[1].to_s
- inFile = File.new('input.txt', 'r')
- def createArray
- rowData = inputFile.split(', ')
- rowReturn = Hash.new
- rowReturn
- end
- def calcAverage
- average = array.reduce(:+) / array.size.to_f
- end
- def calcStandardDeviation
- sum = array.inject(0){|accum, i| accum +(i-average)**2 }
- deviation = sum/(array.length - 1).to_f
- deviation = Math.sqrt(deviation)
- end
- def calcMedian
- sorted = array.sort
- len = sorted.length
- median = (sorted[(len - 1) / 2] + sorted[len / 2]) / 2.0
- end
- def fileIO
- File.open('input.txt', 'r')
- inFile.each_line do |line|
- lineString = line.to_s
- lineSplit = lineString.split(" ")
- end
- inFile.close
- outFile = File.new("output.txt", 'w')
- outFile.print(x.to_s + " " )
- end
- outFile.close()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement