Está en la página 1de 3

UNIVERSIDAD MILITAR NUEVA GRANADA

DEPARTAMENTO DE TECNOLOGÍAS DEL CONOCIMIENTO


PROGRAMACIÓN II
SENTENCIAS CONDICIONALES - IF

Realizar un programa en C++, que le permita al usuario ingresar el nombre del estudiante, la
nota uno, la nota dos, la nota tres y que calcule la definitiva del curso.
 La nota ingresada debe ser validada (0.0 - 5.0) y si se sale del parámetro se imprimir un
mensaje de error.
 Al final se deben imprimir los datos personales del estudiante, las notas, la nota definitiva y
un mensaje donde se diga si el estudiante aprobó o reprobó la materia.

#include <iostream>
#include <string>

using namespace std;

int main()
{
string nomest;
string apelest;
float notauno;
float notados;
float notatres;
float defin = 0;
string salir;
do{
system("cls");
cout << " Ingresar Nombre del Estudiante: ";
cin >> nomest;
cout << " Ingresar Apellido del Estudiante: ";
cin >> apelest;
cout << endl;
cout << " Ingresar la Nota Uno: ";
cin >> notauno;
if (notauno >= 0 && notauno <= 5.0)
{
cout << " Ingresar la Nota Dos: ";
cin >> notados;
if (notados >= 0 && notados <= 5.0)
{
cout << " Ingresar la Nota Tres: ";
cin >> notatres;

Programación II Sentencias Condicionales - IF Página 1


if (notatres >= 0 && notatres <= 5.0)
{
defin = (notauno + notados + notatres) / 3;
if (defin >= 3.0)
{
system("cls"); cout << endl;
cout << " Estudiante: " << nomest << " " << apelest;
cout << endl << endl;
cout << " Nota Uno: " << notauno;
cout << endl;
cout << " Nota Dos: " << notados;
cout << endl;
cout << " Nota Tres: " << notatres;
cout << endl;
cout << endl;
cout << " => Definitiva: " << defin;
cout << endl;
cout << endl;
cout << " === Aprobo la Materia ====";
}
else
{
system("cls");
cout << endl;
cout << " Estudiante: " << nomest << " " << apelest;
cout << endl << endl;
cout << " Nota Uno: " << notauno;
cout << endl;
cout << " Nota Dos: " << notados;
cout << endl;
cout << " Nota Tres: " << notatres;
cout << endl;
cout << endl;
cout << " => Definitiva: " << defin;
cout << endl;
cout << endl;
cout << " === Reprobo la Materia ====";
}
}
else
{
cout << endl;
cout << "\t === Error Nota no Valida ====";
cout << endl;
}
}
else
{
cout << endl;

Programación II Sentencias Condicionales - IF Página 2


cout << "\t === Error Nota no Valida ====";
cout << endl;
}
}
else
{
cout << endl;
cout << "\t === Error Nota no Valida ====";
cout << endl;
}
cout << endl;
cout << endl;
cout << " Realiza Otra Operacion (SI - NO) : ";
cin >> salir;
} while (salir == "si" || salir == "SI");
cout << endl;
cout << endl;
system("pause");
return 0;
}

Programación II Sentencias Condicionales - IF Página 3

También podría gustarte