Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ventureproz/3e845728de43e647b707c9dbc1ee703c to your computer and use it in GitHub Desktop.
Save ventureproz/3e845728de43e647b707c9dbc1ee703c to your computer and use it in GitHub Desktop.
puts "simple calculator"
25.times { print "-" }
puts
puts "enter first number"
num_1 = gets.chomp
puts "enter the second number"
num_2 = gets.chomp
puts "what do you want to do"
puts "(M)ultiple, (D)ivide, (S)ubtraction, (A)ddition, (R)emainder"
type = gets.chomp
puts "You have selected #{type}"
if type == "M"
puts "#{num_1} Times #{num_2} equals #{num_1.to_f * num_2.to_f}"
elsif type == "D"
puts "#{num_1} Divided by #{num_2} equals #{num_1.to_f / num_2.to_f}"
elsif type == "A"
puts "#{num_1} Plus #{num_2} equals #{num_1.to_f + num_2.to_f}"
elsif type == "S"
Puts "#{num_1} minus #{num_2} is #{num_1.to_f - num_2.to_f}"
elsif type == "R"
puts "#The remainder of #{num_1} and #{num_2} is #{num_1.to_f % num_2.to_f}"
else
puts "You need to select the correct input (Input is Case Sensitive)"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment