#!/usr/koeki/bin/ruby total = 0 pt = 0 while true STDERR.print("値段: ") price = gets.chomp if price == "q" break end price = price.to_i total += price pt += (price / 100) printf("価格 %d 円\tポイント %d [pt]\n", total, pt) end STDERR.print("曜日: ") STDERR.print("1. 月\t2. 火\t3. 水\t4. 木\t5. 金\t6. 土\t7. 日\t\n") wday = gets.to_i if wday == 3 printf("金額 %d 円\tポイント %d [pt]\n", total, pt * 10) else printf("金額 %d 円\tポイント %d [pt]\n", total, pt) end