# Run in shell with
# elixir university.exs
defmodule University do
def average(p1, p2), do: (p1 + p2) / 2
def average(p1, p2, p3), do: (p1 + p2 + p3) / 3
defp professor_base_salary(:adjunct, "US$"), do: 20000
defp professor_base_salary(:adjunct, "R$"), do: 30000
defp professor_base_salary(:assistant, currency),
do: 3 * professor_base_salary(:adjunct, currency)
defp professor_base_salary(:associate, currency),
do: 5 * professor_base_salary(:adjunct, currency)
defp professor_base_salary(:full, currency), do: 10 * professor_base_salary(:adjunct, currency)
def professor_annual_salary(name, position, currency) do
{name, professor_base_salary(position, currency), currency}
end
def main() do
IO.puts("Salaries at the University of Some Place (USP)\n")
{name, salary, currency} = professor_annual_salary("John", :full, "US$")
IO.puts("#{name} receives an annual salary of #{currency} #{salary}\n")
{name, salary, currency} = professor_annual_salary("João", :associate, "R$")
IO.puts("#{name} receives an annual salary of #{currency} #{salary}\n")
end
end
University.main()