Skip to content

Instantly share code, notes, and snippets.

@RedSoxFan22
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedSoxFan22/03a8ffeaf695b619a496 to your computer and use it in GitHub Desktop.
Save RedSoxFan22/03a8ffeaf695b619a496 to your computer and use it in GitHub Desktop.
First assignment
puts "Please enter a number."
counter = 0
total = 0
string_total = []
while true
input = gets.chomp
if input.to_i > 0
puts "Good. How about another?"
counter += 1
total += input.to_i
elsif input == ""
if total > 0
puts "Your total is #{total}. Your average is #{total/counter}"
else total == 0
puts "Your words are #{string_total.join}"
end
else input.to_i == 0
puts "That's a string, but we can work with that."
if input.to_i == 0
string_total.push(input)
puts "Do you have another?"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment