Last active
August 29, 2015 14:20
-
-
Save RedSoxFan22/03a8ffeaf695b619a496 to your computer and use it in GitHub Desktop.
First assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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