FastPrepConvert Between Dollars and Euros to the Cent
Problems/Convert Between Dollars and Euros to the Cent

Convert Between Dollars and Euros to the Cent

Capital One logoCapital One● EasyINTERNFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Three Capital One reports from 2018 and 2019 include a currency conversion question: two from intern final rounds ask for a dollars-to-euros function, and a 2019 onsite asks for a euros-to-dollars calculator.

None of them gives the rate, the number format or how to round. In this version the amount and the rate arrive as decimal text, so the same function works in either direction. The result is rounded to the nearest cent with halves going up, and it is returned as text with exactly two decimals, so zero is 0.00. We avoid floating point because it can round a half cent the wrong way. These are our choices.

Our version is about 80% the same as the reported questions.

amount is a money amount written with exactly two decimals, such as "250.00". rate is how many units of the other currency one unit buys, written with one to six decimals, such as "0.91537". The same function converts dollars to euros or euros to dollars; only the rate differs.

Return amount × rate rounded to the nearest cent, where an exact half cent rounds up. Write the result with exactly two decimals and no extra leading zeros, for example "228.84" or "0.00".

Function

convertCurrency(amount: String, rate: String) → String

Examples

Example 1

amount = "250.00"rate = "0.91537"return = "228.84"

250.00 × 0.91537 = 228.8425. The digit after the cents is 2, so the amount rounds down to 228.84.

Example 2

amount = "1.15"rate = "1.5"return = "1.73"

1.15 × 1.5 = 1.725, exactly halfway between 1.72 and 1.73. Halves round up, so the answer is 1.73. Floating-point multiplication gets 1.7249999… here and would round the wrong way.

Example 3

amount = "0.01"rate = "0.4"return = "0.00"

0.01 × 0.4 = 0.004, less than half a cent, so it rounds to 0.00. The answer still shows two decimals.

Constraints

  • amount matches digits.dd with no leading zero before other digits, and 0.01 <= amount <= 10000000.00.
  • rate has a whole part, a dot and 1 to 6 decimals, with no leading zero before other digits, and 0.000001 <= rate <= 100.

More Capital One Onsite Interview questions

  • Digit-Coded Card ValidationONSITE INTERVIEW · Seen Nov 2026
  • Sort ColorsONSITE INTERVIEW · Seen Oct 2026
  • Virtual Card Transaction ValidatorONSITE INTERVIEW · Seen Oct 2026
  • Banking System with Top ActivityONSITE INTERVIEW · Seen Sep 2026
  • Transaction Event StoreONSITE INTERVIEW · Seen Jul 2026
  • Shortest Path in an Unweighted GraphONSITE INTERVIEW · Seen Jul 2026
  • Duplicate Transactions Within 60 SecondsONSITE INTERVIEW · Seen May 2026
  • LRU CachePHONE SCREEN · ONSITE INTERVIEW · Seen May 2026
  • Cashback TrackerONSITE INTERVIEW · Seen Nov 2025
  • Reverse a StringOA · ONSITE INTERVIEW · Seen Oct 2025

Similar questions at other companies

  • Roman to IntegerKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEWKotak Mahindra Bank interview questions
  • Convert Hexadecimal to Dotted IPv4Microsoft · ONSITE INTERVIEWMicrosoft interview questions
  • Palindrome Match PercentageApple · ONSITE INTERVIEWApple interview questions
  • Caesar Cipher with a Precomputed AlphabetAmazon · ONSITE INTERVIEW
  • Add Two Binary StringsPeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Add Two Numeric Strings with CarryZipRecruiter · ONSITE INTERVIEWZipRecruiter interview questions
  • Substrings Made Only of VowelsExpedia · ONSITE INTERVIEWExpedia interview questions
  • Calculate a Token-List ExpressionCollege Vine · ONSITE INTERVIEW
  • Iterate Canonical IPv6 AddressesOpenAI · ONSITE INTERVIEWOpenAI interview questions
  • Nth Staged License PlateGoogle · ONSITE INTERVIEWGoogle interview questions

Capital One interview experiences

  • Capital One Coding OA Questions: 3 Experiences
  • Capital One Experienced Engineer Power Day and OA: 6 Experiences
  • Capital One New Grad OA Questions: 14 Experiences (Part 2 of 2)
  • Capital One TDP Agentic Round (AI Coding): 7 Experiences
  • Capital One SWE Power Day, Level Not Reported: 6 Experiences
  • Capital One TIP Intern OA and Power Day: 13 Experiences
All Capital One interview questionsSee Capital One hiring insights
Saved
class Solution {
    public String convertCurrency(String amount, String rate) {
        // Write your code here.
    }
}
Checking account…