Feature #4: Fare in Words
Explore how to transform numeric Uber ride fares into readable English words. This lesson guides you through splitting large numbers into manageable groups and converting each set into words, including handling special cases like teens, improving your ability to solve real-world coding interview problems.
We'll cover the following...
Description
At the end of a ride, the Uber app displays the fare to the customer. For accessibility, we want the fare to be read out, should the customer so choose. Assuming that the ride fare is an integer and that a text to speech engine is available, all we need to do is to convert the fare to English words. For example, we need to change $120 to one hundred and twenty dollars. The fare may be as high as several billion depending on the country the ride is taken in.
We’ll be provided with an integer number, fare, which represents the fare. Our task will be to convert fare to its English word representation.
Solution
We can solve this problem by ...