#!/usr/local/bin/ruby total = 0 while true STDERR.print "商品名は?: " item = gets.chomp if item == "q" then break end STDERR.print "おいくら?: " price = gets.to_i printf("%-14s %5d円\n", item, price) total += price end print "お買い上げありがとうございました。\n" printf("合計は%6d円です。\n", total)