四則演算
#!/bin/usr/ruby
puts "ã²ã¨ã¤ã‚ã®æ•°ã®å…¥åŠ›"
a = gets.chomp
puts "四則演算åã®å…¥åŠ›"
b = gets.chomp
puts "ãµãŸã¤ã‚ã®æ•°ã®å…¥åŠ›"
c = gets.chomp
case b
when "+"
puts a.to_i + c.to_i
when "-"
puts a.to_i - c.to_i
when "*"
puts a.to_i * c.to_i
when "/"
puts a.to_i / c.to_i
end
å®Ÿè¡Œçµæžœ
t07057@t07057pc:~/Desktop$ ruby 03-1.rb
ã²ã¨ã¤ã‚ã®æ•°ã®å…¥åŠ›
5
四則演算åã®å…¥åŠ›
*
ãµãŸã¤ã‚ã®æ•°ã®å…¥åŠ›
3
15