#!/usr/bin/env ruby fund = 1000 while true printf("残高%d円です。何円出しますか(負の数は入金, 0で終了): ", fund) inout = gets.to_i break if inout == 0 # ifを文の後ろにつけると1行で書ける fund -= inout end