Use Ruby's Switch Statement to Build a Currency Converter

In this coding exercise you'll learn how to build a currency converter method in Ruby, including how to utilize advanced string interpolation.

Using Ruby Benchmark

View Video

Summary

Build a currency converter method that can format the currency for the: US, Japan, and UK based currencies.

Exercise File

Code File

Example Input

5000, 'US'

Write a program that formats the data into a location based currency.

Example Output

"$5000.00"

Real World Usage

This is a common coding interview question since it forces you to work with multiple scenarios and perform string manipulation. This is also important when it comes to understanding how to utilize varying string interpolation options related to financial data.

Solution

Can be found on the solutions branch on github.

Jordan Hudgens

Jordan Hudgens

I've been a software engineer for the past decade and have traveled the world building applications and training individuals on a wide variety of topics.


View All Posts