Drill

ProblemsC# › finance

Convert between currencies

easyfinanceMathC#

A money-changer converts an amount in minor units at a rate quoted in basis points (per ten thousand).

CurrencyConvert(amountMinor: int, rateBps: int) → int

C# needs a compiler and Drill does not host one yet, so this page is the reference rather than an exercise: the problem, worked examples, and the solution in full. To type it out, the same problem runs in Python.

Solve it in Python →

Where you start

public int CurrencyConvert(int amountMinor, int rateBps) {
    
}

Worked examples

CallResult
CurrencyConvert(1000, 8000)800
CurrencyConvert(500, 10000)500
CurrencyConvert(1250, 3333)416
CurrencyConvert(0, 5000)0

Hint

Multiply then divide by 10000, rounding down.

Reference solution in C#
public int CurrencyConvert(int amountMinor, int rateBps) {
    return (amountMinor * rateBps) / 10000;
}

The same problem in another language

More finance problems in C#