FastPrepReturn Exact Cash Register Change
Problems/Return Exact Cash Register Change

Return Exact Cash Register Change

Bank of America logoBank of America● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Bank of America full-time online assessment. The report gives the cash-register outcomes, the coin and bill values, and an alphabetical order for the results. Here amounts are exact decimal strings and the answer is one comma-separated string, so there is one portable interface.

Given the purchase price purchasePrice and the cash paid cashPaid as exact decimal strings, return a string that describes the change.

If the cash paid is less than the purchase price, return ERROR. If the amounts are equal, return ZERO. Otherwise, make the exact change with the fewest coins and bills, using these values: PENNY (0.01), NICKEL (0.05), DIME (0.10), QUARTER (0.25), HALF DOLLAR (0.50), ONE (1.00), TWO (2.00), FIVE (5.00), TEN (10.00), TWENTY (20.00), FIFTY (50.00), and ONE HUNDRED (100.00).

List one name for each coin or bill used, so a name repeats when that value is used more than once. Sort the names alphabetically and join them with commas.

Function

cashRegister(purchasePrice: String, cashPaid: String) → String

Examples

Example 1

purchasePrice = "12.37"cashPaid = "20.00"return = "DIME,FIVE,HALF DOLLAR,PENNY,PENNY,PENNY,TWO"

The change is 7.63. The fewest coins and bills that make it are FIVE, TWO, HALF DOLLAR, DIME, PENNY, PENNY and PENNY, and the output lists them sorted alphabetically.

Example 2

purchasePrice = "35.00"cashPaid = "35.00"return = "ZERO"

No change is due because the two amounts are equal.

Example 3

purchasePrice = "10.00"cashPaid = "5.00"return = "ERROR"

The cash paid is less than the purchase price.

Constraints

  • Each input is a valid nonnegative decimal string with one or two fractional digits.
  • 0.00 <= purchasePrice, cashPaid <= 1000000.00
  • The inputs contain no currency symbols, grouping separators, signs, or surrounding whitespace.

More Bank of America Online Assessment questions

  • Sum Skipping Multiples of 7OA · Seen Nov 2025
  • Wildcard Substring MatchOA · Seen Nov 2025
  • Maximum String BeautyOA · Seen Sep 2024
  • Sum Skipping Multiples of 5 or 7OA · Seen Sep 2024
  • Merge Point of Two Linked ListsOA · Seen Oct 2023
  • Remove Duplicates from a ListOA · Seen Oct 2023
  • Pairs with Target Sum in a Sorted ArrayOA · Seen Oct 2023
  • Count Level-Order Traversals of a TreeOA · Seen Sep 2023
  • Count Set BitsOA · Seen Sep 2023
  • Count Pairs with Sum KOA · Seen Jun 2023

Similar questions at other companies

  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Maximize Workday EarningsCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
  • Largest Binary Number by ConcatenationAdobe · OAAdobe interview questions
  • Maximize Palindromic WordsSquarepoint Capital · OASquarepoint Capital interview questions
  • Minimum Digit Swaps for the Smallest DifferenceLSEG · OALSEG interview questions
  • Swap Parity (Data Scientist / Analytics :)JP Morgan Chase · OAJP Morgan Chase interview questions
  • Doing Smart WorkRubrik · OARubrik interview questions
  • Swap ParityPalantir · OAPalantir interview questions
  • Assigned ParkingAirbnb · OAAirbnb interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions

Bank of America interview experiences

  • Bank of America OA · April 2014
  • Bank of America interviews · April 2014
  • Bank of America OA · February 2013
  • Bank of America interviews · February 2013
  • Bank of America interviews · November 2020
  • Bank of America OA · December 2020
All Bank of America interview questionsSee Bank of America hiring insights
Saved
class Solution {
    public String cashRegister(String purchasePrice, String cashPaid) {
        // Write your code here.
    }
}
Checking account…