Skip to content

Instantly share code, notes, and snippets.

@patrick-gleeson
Last active March 2, 2020 09:09
Show Gist options
  • Save patrick-gleeson/58b3d7960dbebbc6cd2ce3335e468ef9 to your computer and use it in GitHub Desktop.
Save patrick-gleeson/58b3d7960dbebbc6cd2ce3335e468ef9 to your computer and use it in GitHub Desktop.
Funky Finance Challenge

Funky Finance

The leadership team at Loan-U-Like are worried about morale among their loan advisors. Advisors spend hours working out loan details for their customers using drab, boring hand-held calculators, and they're reporting low levels of job satisfaction.

The solution: software. And not just software. Fun software. You have been commissioned to write a program that enables users to perform calculations quickly and easily. To make it a cheerful experience, all numbers output by the software must be displayed in something called 'FunkyFont', a set of glyphs bought at great expense from a trendy continental design agency.

Business Logic

Loan-U-Like offers 'interest-only' loans. Customers borrow a lump sum for a set period of time, and every year must pay off that year's interest in full. At the end of the time period, they must pay off the original sum as well.

The program must facilitate calculations that help advisors explain the details of the loans to their customers, using the formula:

I = Prt

I is the total amount of interest paid off by the customer over the course of the loan, P is the amount of money borrowed, r is the annual interest rate, and t is the number of years before the loan is paid off. For example if a customer takes out a £2000 loan (P), with a 1% interest rate (r), for 10 years (t), the total amount of money they will pay in interest payments (I) is:

£2000 * 1%/year * 10 years = £200

In each case, the user (a Loan-U-Like advisor), will know the value for any three of the variables I, P, r and t, and use the program to calculate the fourth. E.g. if I, P and r are known, the program will calculate t = I/(Pr).

User Interface

Advisors have Ruby and Node installed on their computers, and will run the program from the terminal, by typing ruby funky_finance.rb/node funkyFinance.js or similar.

The program should initially print to the console: Welcome to Funky Finance!. It should then ask: What sort of number is the first variable? (Please enter i, p, r or t), and allow the user to enter one of those 4 values. Once a valid choice has been made, it should say: Please now enter the first variable and allow the user to enter a number. It should reject any value other than a number with up to 2 decimal places.

It should then ask for second and third variables in the same way. Once three variables have been provided, it should output the calculated value of the fourth variable.

Furthermore, the output should be in FunkyFont, using the glyphs specified in the appendix below. So, for example, if the calculated value was 4.37, the program would output:

=============
@ @   @@@ @@@
@ @     @   @
@@@   @@@   @
  @     @   @
  @ @ @@@   @
=============

Once the calculated value has been shown on screen, the program should exit.

Format

Please write your code as one or more files, and put them into a private repository on Github. Ideally you will commit your work as you go, using sensible commit messages for each chunk of work. When you are done, please invite @patrick-gleeson as a collaborator on your repository.

Appendix

Below are the FunkyFont glyphs corresponding to the characters 1-9, . and (space). There should be a space between every glyph.

===
@@@
@ @
@ @
@ @
@@@
===
=
@
@
@
@
@
=
===
@@@
  @
@@@
@
@@@
===
===
@@@
  @
@@@
  @
@@@
===
===
@ @
@ @ 
@@@
  @
  @
===
===
@@@
@ 
@@@
  @
@@@
===
===
@@@
@ 
@@@
@ @
@@@
===
===
@@@
  @
  @
  @
  @
===
===
@@@
@ @
@@@
@ @
@@@
===
===
@@@
@ @
@@@
  @
@@@
===
=




@
=
=





=
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment