Is a program the calculate students averages. It can return the best average of a student, and the student with the best average in the school.
git clone https://github.com/rafaelacorrea/school
Open terminal in the school directory, and execute the command:
iex -S mix
When the iex is activate, we add the command below to see the registered students:
iex> {result, best} = AverageCalculator.start()
and it returns:
{[
%{average: 7.5, first_name: "Frank", last_name: "Ferreira"},
%{average: 6.68, first_name: "Aneliza", last_name: "Ferreira"},
%{average: 6.55, first_name: "Rafaela", last_name: "Carvalho"},
%{average: 4.48, first_name: "Andre", last_name: "Carvalho"}
], [%{average: 7.5, first_name: "Frank", last_name: "Ferreira"}]}
To consult the average result of the students, we use the command below:
iex> result
It returns:
[
%{average: 6.88, first_name: "Rafaela", last_name: "Carvalho"},
%{average: 8.2, first_name: "Frank", last_name: "Ferreira"},
%{average: 4.78, first_name: "Aneliza", last_name: "Ferreira"},
%{average: 4.21, first_name: "Andre", last_name: "Carvalho"}
]
To know the student with the best average, we use the fallowing command:
iex> best
and the return is:
[%{average: 8.2, first_name: "Frank", last_name: "Ferreira"}]