Created
July 2, 2018 09:35
-
-
Save cyrusthecool/51f053667e5a5a8aa0bf9e15d2b9062e 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
def show_menu | |
puts "Calculator" | |
puts"-" * 40 | |
puts "[a] - Addition" | |
puts "[m] - Multiplication" | |
puts "[s] - Subtraction" | |
puts "[d] - Division" | |
puts "[r] - Square Root" | |
puts "[e] - Exponent" | |
puts "[f] - Finance Calculation" | |
puts "[t] - Trip Calculation" | |
puts "[q] - Quit" | |
puts"-" * 40 | |
print "Enter your selection:" | |
end | |
show_menu | |
menu_choice = gets.chomp.downcase | |
until menu_choice == 'q' | |
case menu_choice | |
when'a' | |
def addition_function | |
puts "Which numbers would you like to add?" | |
n1 = gets.chomp.to_i | |
n2 = gets.chomp.to_i | |
answer = n1 + n2 | |
puts "The sum is: #{answer}" | |
end | |
addition_function | |
show_menu | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment