#!/usr/koeki/bin/ruby # coding: utf-8 price = Hash.new(0) price["りんご"] = 150 price["みかん"] = 30 price["いちご"] = 20 price["梨"] = 120 puts "りんご、みかん、いちご、梨、のどの値段を知りたいですか?" what = gets.chomp! cost = price[what] printf("%sは1個%d円です\n", what, cost) if cost == 0 printf("っていうか%sは売ってないんで...\n", what) end