var notasAlunos = new Dictionary<string, Dictionary<string, List<int>>> {
{ "Ana", new Dictionary<string, List<int>> {
{ "C#", new List<int> { 8, 7, 6 } },
{ "Java", new List<int> { 7, 6, 5 } },
{ "Python", new List<int> { 9, 8, 8 } }
}},
{ "Maria", new Dictionary<string, List<int>> {
{ "C#", new List<int> { 6, 5, 4 } },
{ "Java", new List<int> { 8, 7, 6 } },
{ "Python", new List<int> { 6, 10, 5 } }
}},
{ "Luiza", new Dictionary<string, List<int>> {
{ "C#", new List<int> { 2, 3, 10 } },
{ "Java", new List<int> { 8, 8, 8 } },
{ "Python", new List<int> { 7, 7, 7 } }
}}
};
double Media(string nome, string disciplina)
{
try
{
List<int> notasPorDisciplina = notasAlunos![nome][disciplina];
double media = notasPorDisciplina.Average();
return media;
}
catch (System.Exception)
{
Console.WriteLine("Nome não encontrado");
throw;
}
}
Console.Write("Qual o nome do aluno que deseja saber a média? ");
string nomeAluno = Console.ReadLine()!;
Console.Write("Qual a disciplina? ");
string disciplinaAluno = Console.ReadLine()!;
Console.Write(Media(nomeAluno,disciplinaAluno));