コンバーターを作成する作業に数時間苦労しました。ある通貨から別の通貨に変換する必要があります。これはコードです。
def converter
puts "Enter the amount you wish to convert"
userAmount = gets
puts "Enter your choice: 1 for converting Qatari
Riyals to US Dollars"
puts "Enter your choice: 2 for converting USD ollars to Qatari Riyals"
choiceConvert = gets
while choiceConvert != 1 || choiceConvert != 2 do
puts "please enter either 1 or 2"
choiceConvertNew = gets
choiceConvert = choiceConvertNew
end
if choiceConvert == 1
convertedAmount = userAmount / 3.65
puts "Your choice is to convert #{userAmount} Qatari Riyals to US Dollars;
You get #{convertedAmount} US Dollars"
else
convertedAmount = userAmount * 3.65
puts "Your choice is to convert #{userAmount} US Dollars to Qatari Riyals;
You get #{convertedAmount} Qatari Riyals"
end
end
converter