[ create a new paste ] login | about

Link: http://codepad.org/Zr2Xm5Yk    [ raw code | output | fork ]

Ruby, pasted on Mar 13:
1
2
3
4
5
6
7
8
9
10
11
12
13
puts "何年物と何年物を比べますか?短い期間の年数を入力して下さい"
initial_y = gets.to_i
puts "長い期間の年数を入力して下さい"
final_y = gets.to_i
puts "#{initial_y}年の金利を入力して下さい(例:1%なら1)"
initial_i = gets.to_i.quo(100) + 1
puts "#{final_y}年の金利を入力して下さい(例:1%なら1)"
final_i = gets.to_i.quo(100) + 1
nensu = final_y - initial_y
nensugyaku = 1.quo(nensu)
kinri = ((((final_i ** final_y).quo(initial_i ** nensu) ** (nensugyaku)) - 1) * 100).to_f

puts "#{initial_y}->#{final_y}年の金利は#{kinri}です"


Output:
1
2
3
4
5
何年物と何年物を比べますか?短い期間の年数を入力して下さい
長い期間の年数を入力して下さい
0年の金利を入力して下さい(例:1%なら1)
0年の金利を入力して下さい(例:1%なら1)
0->0年の金利は0.0です


Create a new paste based on this one


Comments: