Виктор обнови решението на 11.10.2015 19:58 (преди около 9 години)
+def rounds_to_second_sign_after_comma(value)
+ value=value*100
+ remainder=value%1
+ if remainder>=0.5
+ round_value=value.ceil/100.0
+ else
+ round_value=value.floor/100.0
+ end
+ round_value
+end
+def convert_to_bgn(value, currency)
+ if currency==:usd
+ rounds_to_second_sign_after_comma(value*1.7408)
+ elsif currency==:eur
+ rounds_to_second_sign_after_comma(value*1.9557)
+ elsif currency==:gbp
+ rounds_to_second_sign_after_comma(value*2.6415)
+ else
+ value
+ end
+end
+def compare_prices(first_value, first_currency, second_value, second_currency)
+ first_price=convert_to_bgn(first_value, first_currency)
+ second_price=convert_to_bgn(second_value, second_currency)
+ first_price-second_price
+end
+puts compare_prices(100, :usd, 100, :bgn)