Skip to content

Instantly share code, notes, and snippets.

@FaisalFehad
Created December 14, 2016 22:26
Show Gist options
  • Save FaisalFehad/fa7b83579c17a2579d700c49a81c004a to your computer and use it in GitHub Desktop.
Save FaisalFehad/fa7b83579c17a2579d700c49a81c004a to your computer and use it in GitHub Desktop.
Simple script to calculate UCAS points
puts 'How many units did you achive?'
total_units = gets.to_i
# validations for the input format
if total_units == 0
puts 'Please enter a number that is greater than 0.'
end
#Counters
total_points = 0
submited_counter = 0
asking_counter = 1
while total_units > submited_counter do
puts "What did you achive in the #{asking_counter} unit?"
grage_input = gets.capitalize.chomp
#Validates the user's second input
until grage_input == "Pass" || "Merit" || "Distenction" do
puts "You can only enter Pass Merit or Distenction here."
grage_input = gets.capitalize.chomp
end
if grage_input == 'Pass'
total_points += 70
submited_counter += 1
asking_counter += 1
elsif grage_input == 'Merit'
total_points += 80
submited_counter += 1
asking_counter += 1
elsif grage_input == 'Distenction'
total_points += 90
submited_counter += 1
asking_counter += 1
else
puts 'Please enter Pass, Merit or Distenction and then pess enter.'
end
end
# Total achived points
puts "You have achived #{total_points} poins."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment