Advertisement
Guest User

Calculator

a guest
Jan 18th, 2013
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.84 KB | None | 0 0
  1. puts "Add, Subtract, Divide, or Multiply?"
  2.  
  3. command = gets.chomp
  4.  
  5. if command == "add"
  6.     puts "Type in the first number, press enter, then type the other num."
  7.     add1 = gets.chomp
  8.     add2 = gets.chomp
  9.     puts add1.to_f + add2.to_f
  10. end
  11.  
  12. if command == "subtract"
  13.     puts "Type in the first number, press enter, then type the other num."
  14.     sub1 = gets.chomp
  15.     sub2 = gets.chomp
  16.     puts sub1.to_f - sub2.to_f
  17. end
  18.  
  19. if command == "divide"
  20.     puts "Type in the first number, press enter, then type the other num."
  21.     div1 = gets.chomp
  22.     div2 = gets.chomp
  23.     puts div1.to_f / div2.to_f
  24. end
  25.  
  26. if command == "multiply"
  27.     puts "Type in the first number, press enter, then type the other num."
  28.     mult1 = gets.chomp
  29.     mult2 = gets.chomp
  30.     puts mult1.to_f * mult2.to_f
  31. end
  32.  
  33. puts "Would you like to calculate again?"
  34.  
  35. command1 = gets.chomp
  36.  
  37. if command1 == "no"
  38. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement