Skip to content

Instantly share code, notes, and snippets.

View FaisalFehad's full-sized avatar
🎯
Focusing

Faisal Fehad FaisalFehad

🎯
Focusing
  • Sky UK
View GitHub Profile
def upcase_words(words)
puts "#{words}".upcase
end
def downcase_words(words)
puts "#{words}".downcase
end
downcase_words("hEllo My DeAr")
puts "hEllo My DeAr".upcase
puts "hEllo My DeAr".downcase
@FaisalFehad
FaisalFehad / calc_method.rb
Created September 8, 2016 15:45
calc_method
# 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"
# 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