Algoritmo para el cálculo de nota definitiva de un estudiante
Veamos el diseño del algoritmo que calcula la nota definitiva de un estudiante, en función de 3 notas parciales equivalentes al 35%, 40% y 25% respectivamente.
El algoritmo debe indicar si el estudiante aprobó o no la materia. Tome en cuenta que las notas son valores del 0 al 10. Se aprueba con 4.5 puntos o más.
En caso de que la nota definitiva indique que el estudiante reprobó, el algoritmo debe verificar si el estudiante tiene al menos una de las notas con valor por encima o igual a 7 puntos o más, de tal forma que se le puedan sumar 0.5 puntos.
ALGORITMO CALCULO NOTA
DECLARACIÓN
CONSTANTES
PORC1=0.35
PORC2=0.40
PORC3=0.25
VARIABLES
EXAM1, EXAM2,EXAM3, NOTA1,NOTA2,NOTA3,DEFI: REAL
INICIO
ESCRIBIR “ALGORITMO
QUE CALCULA LA NOTA DEFINITIVA DE UN ESTUDIANTE”
ESCRIBIR”NOTA DEL EXAMEN 1”
LEER EXAM1
ESCRIBIR”NOTA DEL EXAMEN 2”
LEER EXAM2
ESCRIBIR”NOTA DEL EXAMEN 3”
LEER EXAM3
SI (EXAM1>=0 Y
EXAM2>=0 Y EXAM3>=0) ENTONCES
NOTA1 <= EXAM1*PORC1
NOTA2 <= EXAM2*PORC2
NOTA3 <= EXAM3*PORC3
DEFI <= NOTA1+NOTA2+NOTA3
SI (DEFI>=4 Y DEFI<=4.4) ENTONCES
SI (EXAM1>=7 O EXAM2>=7 O EXAM3>= 7) ENTONCES
DEFI <= DEFI + 0.5
FIN SI
FIN SI
SI (DEFI>= 4.5) ENTONCES
RESPUESTA <= ”APROBÓ”
SINO
RESPUESTA <= ”REPROBRÓ”
FIN SI
ESCRIBIR “EL ESTUDIANTE “, RESPUESTA, “LA
MATERIA CON “, DEFI, “Ptos.”
ESCRIBIR ”ERROR, LAS NOTAS DEBEN SER VALORES ENTRE 0 Y 10”
FIN SI
FIN
Observemos su respectiva codificación en lenguaje C++
#include <iostream>
using namespace std;
const float PORC1= 0.35;
const float PORC2=0.40;
const float PORC3=0.25;
int main(){
float EXAM1, EXAM2,EXAM3, NOTA1,NOTA2,NOTA3,DEFI;
char RESPUESTA[8]; //declaracion de una variable tipo cadena
cout <<"PROGRAMA QUE CALCULA LA NOTA DEFINITIVA DE UN ESTUDIANTE \n";
cout<<"NOTA DEL EXAMEN 1\n";
cin>> EXAM1;
cout<<"NOTA DEL EXAMEN 2\n";
cin>>EXAM2;
cout<<"NOTA DEL EXAMEN 3\n";
cin>>EXAM3;
if (EXAM1>=0 && EXAM2>=0 && EXAM3>=0){
NOTA1=EXAM1*PORC1;
NOTA2=EXAM2*PORC2;
NOTA3=EXAM3*PORC3;
DEFI=NOTA1+NOTA2+NOTA3;
if (DEFI>=4 && DEFI<=4.4)
if (EXAM1>=7 || EXAM2>=7 || EXAM3>= 7)
DEFI=DEFI+ 0.5;
if (DEFI>= 45)
strcpy(RESPUESTA,"APROBO");
else
strcpy(RESPUESTA,"REPROBRO");
cout<< "\nEL ESTUDIANTE "<<RESPUESTA<<" LA MATERIA CON "<<DEFI<< " Ptos.\n";
}
else
cout<<"\n ERROR, LAS NOTAS DEBEN SER VALORES ENTRE 0 Y 10";
system("pause");
}//fin del main