Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace listado_notas_promediadas
- {
- class Program
- {
- static void Main(string[] args)
- {
- String strNombre, strNota;
- Double dblNota = 0;
- bool blDetermine = false;
- Dictionary<string, Array> di = new Dictionary<string, Array>();
- Console.WriteLine("Calcula el promedio de notas de 11 Estudiantes! \n\n");
- for(int i=1;i<12;i++){
- Console.WriteLine("Introduzca la información del estudiante "+i+"");
- Console.Write("Nombre: ");
- strNombre = Console.ReadLine();
- double[] nota_mes = new double[4];
- for (int j = 0; j < 4; j++)
- {
- Console.Write("Introduzca la nota " + (j+1) + " de "+strNombre+": ");
- strNota = Console.ReadLine();
- blDetermine = Double.TryParse(strNota, out dblNota);
- if (blDetermine == false)
- {
- Console.WriteLine("\n\nFavor de escribir un valor correcto! Ej: 85");
- }
- nota_mes[j] = dblNota;
- }
- di.Add(strNombre, nota_mes);
- }
- foreach (var d in di)
- {
- Console.WriteLine();
- Console.WriteLine($"el promedio cuatrimestral de notas de {d.Key} es: {PromedioNota(d.Value)}");
- Console.WriteLine($"{d.Key} obtuvo una -> " + Promedio(PromedioNota(d.Value)));
- }
- }
- static Double[] ObetenerPromedioNotas(Dictionary<string,Array> di) {
- double[] result=new double[4];
- double sum=0;
- for (int i = 0; i <4; i++) {
- double[] de = new double[di.Count];
- int j = 0;
- foreach (double[] s in di.Values) {
- de[j]= s[i];
- j++;
- }
- for (int k = 0; k < de.Length; k++) {
- sum += de[k];
- }
- result[i] = sum / di.Count;
- sum = 0;
- }
- return result;
- }
- static double PromedioNota(Array Notames)
- {
- double sum=0;
- foreach (double a in Notames) {
- sum+=a;
- }
- return sum / 4;
- }
- static string Promedio(double avg)
- {
- if (avg >= 90 && avg <= 100)
- {
- return "A";
- }
- else if (avg >= 80 && avg <= 89)
- {
- return "B";
- }
- else if (avg >= 70 && avg <= 79)
- {
- return "C";
- }
- else if (avg >= 60 && avg <= 69)
- {
- return "D";
- }
- else if (avg >= 0 && avg <= 59)
- {
- return "F";
- }
- return "None";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement