Created
September 23, 2010 23:43
-
-
Save divoxx/594614 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 "Type 'end' at any point to calculate the average." | |
| marks = [] | |
| sum = 0 | |
| while mark != "end" | |
| print "Enter Mark: " | |
| mark = gets.chomp | |
| break if mark == "end" | |
| begin | |
| mark = Float(mark) | |
| marks << mark | |
| sum = sum + mark | |
| rescue ArgumentError | |
| puts "Invalid mark #{mark}" | |
| end | |
| end | |
| average = sum / marks.size | |
| puts "The Average grade of the class is #{average}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment