-module(coffee).-include_lib("eunit/include/eunit.hrl").-export([coffee/1]).coffee(X)->P=coffee_price(X),casePoffalse->"Sorry, exact change only, try again tomorrow!";_->"Here is your "++P++", have a nice day!"end.coffee_price(2.20)->"Americano";coffee_price(2.30)->"Latte";coffee_price(2.40)->"Flat white";coffee_price(3.50)->"Filter";coffee_price(_)->false.americano_test()->?assert(coffee(2.20)=="Here is your Americano, have a nice day!").latte_test()->?assert(coffee(2.30)=="Here is your Latte, have a nice day!").flat_white_test()->?assert(coffee(2.40)=="Here is your Flat white, have a nice day!").filter_test()->?assert(coffee(3.50)=="Here is your Filter, have a nice day!").invalid_test()->?assert(coffee(4.90)=="Sorry, exact change only, try again tomorrow!").
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Erlang solution with tests.