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
def upcase_words(words) | |
puts "#{words}".upcase | |
end | |
def downcase_words(words) | |
puts "#{words}".downcase | |
end | |
downcase_words("hEllo My DeAr") |
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 "hEllo My DeAr".upcase | |
puts "hEllo My DeAr".downcase |
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
# A method that takes one array of any size as an argument and prints faild when the average total grades is 50 or more and pass when its less than 50 | |
def calculate(grades) | |
# countes the number of objects in the array and assign it to subjects varible to use it latter for calculating the average | |
subjects = grades.count | |
# sums all of the array objects and assign them to the varible sum | |
sum = grades.inject(:+) | |
# compares sum with the passing grade and prints the resuts | |
if sum / subjects >= 50 | |
puts "Faild" |
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
# an empty array to store the grades | |
grades = [] | |
# variables for the passing grade and the total number of subjects. You can change them from here. | |
pass_grade = 50 | |
subjects = 7 | |
# loops until reaches the the number of subjects on the subjects variable | |
while grades.count < subjects | |
# prints the message |
NewerOlder