I'm trying to solve an exercise that looks like this:
Make an algorithm that reads the height and enrollment of ten students. Show highest student enrollment and lowest student enrollment
And my code at the moment looks like this:
Console.WriteLine("Altura dos Alunos");
for ( int i = 0; i <= 10; i++)
{
Console.WriteLine("Qual a sua altura: ");
double altura = Convert.ToDouble(Console.ReadLine ());
Console.WriteLine("Qual sua matrícula? Ex: 1234");
int matricula = Convert.ToInt32(Console.ReadLine());
double altura2 = 0;
Math.Max( altura, altura2 );
altura2 = altura;
}
How do I use the Math.Max()
method to get the highest height and show it later without having to create 10 variables?