#m!?/usr/bin/env ruby
# -*- coding: utf-8 -*-

puts"残金入力"
zann = gets.chomp.to_i


okane = 0

while true
  puts "買った物の値段は?(終わるならvと入力)"
  nedan = gets.chomp

if nedan == "v"
  break
end

 okane += nedan.chomp.to_i
 printf("小計は%d円\n",okane)
end

printf("合計%d円\n",okane)
zann -= okane.to_i
printf("残高は%d円\n",zann)
