1971年の10進数化まで、英国のお金はポンドを240ペニーに分割することに基づいていました。シリングは12ペニーでしたので、20シリングはポンドになりました。最小額面は、ペニーの4分の1のファージングでした。コインには他にも多くの宗派やニックネームがありましたが、システムに慣れていない場合はかなり混乱する可能性があります。
チャレンジ
(ほとんど)古い英語の金銭を他の金銭に変換できるプログラムまたは関数を作成します。ユーザーが使いやすくするには、複数形とニックネームをサポートする必要があります。
これらはあなたが支持しなければならない宗派とそれらの同義語です。便宜上、ファージングでの価値が各ラインをリードしています。
1: farthing, farthings
2: halfpence, halfpenny, halfpennies
4: penny, pennies, pence, copper, coppers
8: twopenny, twopennies, twopence, tuppence, half groat, half groats
12: threepence, threepenny, threepennies, threepenny bit, threepenny bits, thruppence, thrupenny, thrupennies, thrupenny bit, thrupenny bits
16: groat, groats
24: sixpence, sixpenny, sixpennies, sixpenny bit, sixpenny bits, tanner, tanners
48: shilling, shillings, bob
96: florin, florins, two bob bit, two bob bits
120: half crown, half crowns
240: crown, crowns
480: half sovereign, half sovereigns
504: half guinea, half guineas
960: pound, pounds, pounds sterling, sovereign, sovereigns, quid, quids
1008: guinea, guineas
(私はイギリス人ではありません。このリストは決して権威あるものではありませんが、挑戦には十分です。)
stdinまたは関数引数を使用して、次の形式の文字列を取得する必要があります
[value to convert] [denomination 1] in [denomination 2]
返品または印刷
[value to convert] [denomination 1] is [converted value] [denomination 2]
ここ[converted value]
で、[value to convert]
単位1 は単位2に変換されます。
[value to convert]
と[converted value]
正の浮動小数点数です。出力では、両方を小数点以下4桁に丸めるか、切り捨てる必要があります。必要に応じ[value to convert]
て、入力時に常に小数点とゼロがあると仮定することができます(例:の1.0
代わりに1
)。
名称1および2は、上記のリストの任意の2つの用語です。それらが複数であるかどうかを心配せずに、すべての宗派と同義語を同じように扱います。入力形式と金種は常に有効であると想定できます。
例
1 pounds in shilling
→ 1 pounds is 20 shilling
(1.0000 pounds is 20.0000 shilling
大丈夫です)
0.6 tuppence in tanner
→ 0.6 tuppence is 0.2 tanner
24 two bob bits in pounds sterling
→ 24 two bob bits is 2.4 pounds sterling
144 threepennies in guineas
→ 144 threepennies is 1.7143 guineas
得点
quid
ですquid
。おそらく、これは古いお金でも同じだったでしょう。例:Five quid a pint! Cor blimey guvnor
。例外:クイッドイン