Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 16, 2021 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/30ab865d2de2069cf27b11af6043a2c3 to your computer and use it in GitHub Desktop.
Save parzibyte/30ab865d2de2069cf27b11af6043a2c3 to your computer and use it in GitHub Desktop.
/*
https://parzibyte.me/blog
*/
#include <iostream>
using namespace std;
int main()
{
// Declarar la cantidad de notas por si el valor cambia
const int cantidadNotas = 5;
double notas[cantidadNotas];
// Solicitar notas
for (int i = 0; i < cantidadNotas; i++)
{
cout << "Ingrese la nota " << i + 1 << ": ";
// Guardar en el arreglo
cin >> notas[i];
}
// Solicitar calificación de examen semestral
double calificacionExamenSemestral;
cout << "Ingrese calificación de examen semestral: ";
cin >> calificacionExamenSemestral;
// Ahora vamos a hacer cálculos
// La sumatoria para promediar
double sumatoria = 0;
// Recorrer notas, imprimir y sumar a la sumatoria
for (int i = 0; i < cantidadNotas; i++)
{
sumatoria = sumatoria + notas[i];
cout << "Nota " << i + 1 << " . Calificación: " << notas[i] << endl;
}
double promedioNotas = sumatoria / cantidadNotas;
// Momento de calcular el promedio final
double promedioFinal = (promedioNotas + calificacionExamenSemestral) / 2;
// Calcular la letra
string letra = "";
if (promedioFinal == 100)
{
letra = "A";
}
else if (promedioFinal >= 80)
{
letra = "B";
}
else if (promedioFinal >= 70)
{
letra = "C";
}
else if (promedioFinal >= 60)
{
letra = "D";
}
else
{
letra = "E";
}
// Imprimir resultados
cout << "Total notas parciales: " << sumatoria << endl;
cout << "Promedio notas parciales: " << promedioNotas << endl;
cout << "Nota del semestral: " << calificacionExamenSemestral << endl;
cout << "Nota final: " << promedioFinal << ". Obtiene " << letra << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment