Guest User

Untitled

a guest
Nov 9th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2.  
  3. ##Justin Beitz
  4. ##Assignment 3
  5.  
  6. def create_array (data)
  7. data.chomp.split(' ').map(&:to_i) # returns array of ints
  8. end
  9.  
  10. def calc_average (data)
  11. average = data.reduce(:+) / data.size.to_f
  12. end
  13.  
  14. unless ARGV[0].to_s == "input.txt"
  15. puts "Wrong input"
  16. end
  17.  
  18. unless ARGV[1].to_s == "output.txt"
  19. puts "Wrong output"
  20. end
  21.  
  22.  
  23. input = ARGV[0].to_s
  24. output = ARGV[1].to_s
  25.  
  26.  
  27. def fileIO
  28.  
  29. in_file = File.new(ARGV[0], 'r')
  30. store = in_file.each_line do |line|
  31. array_of_ints = create_array(line)
  32. avgerage = calc_average(line)
  33. median = calc_median(line)
  34. end
  35. end
  36.  
  37.  
  38.  
  39.  
  40.  
  41. fileIO
Advertisement
Add Comment
Please, Sign In to add comment