
EJERCICIOS DE TERCERA PRACTICA
#include <iostream>
#include <math.h>
using namespace std;
int Opcion, dias, horas, minutos, segundos, segundostotales;
int CALCULAR_SEGUNDOS(int d, int m, int h, int s);
double A,B,P,Xc, Xl, Z, R, L, C, w;
float IMPEDANCIA (double x, double y, double z); // 2.ASIGNACIOON
float PHASE (double p, double q, double r);
float nota1, nota2, nota3, notafinal; //3. ASIGNACION
float NOTA_FINAL(float nota1, float nota2, float nota3);
int a, b, c;
int mayorde (int a, int b, int c);
int main()
{
do
{
cout<<" M E N U \n";
cout<<"------------ \n";
cout<<"1.- Calculo de la IMPEDANCIA \n";
cout<<"2.- CALCULO DE FASE \n";
cout<<"3.- PLANTEADO 1 \n";
cout<<"4.- PLANTEADO 2 \n";
cout<<"INGRESE UNA OPCION <> 0: "; cin>>Opcion;
switch (Opcion)
{
case 1:
{
cout<<endl;
cout<<"1.- CALCULO DE IMPEDANCIA \n";
cout<<"Ingrese la resistencia R = "; cin>>R;
cout<<"Ingrese la inductancia L = "; cin>> L;
cout<<"Ingrese la capacitanica C = "; cin>> C;
cout<<"Ingrese la veloc angular w = "; cin>>w;
Xc = 1/(w*C);
Xl = w*L;
B = IMPEDANCIA (R, Xl, Xc); // 1. INVOCACION
cout<<"La impedancia Z = "<<B; //5. respuesta
cout<<endl;
}; break;
case 2:
{
cout<<"2.- CALCULO DE FASE \n";
cout<<endl;
cout<<endl;
cout<<"1.- CALCULO DE IMPEDANCIA \n";
cout<<"Ingrese la reactancia inductiva Xl = "; cin>>Xl;
cout<<"Ingrese la reactancia capacitiva Xc = "; cin>>Xc;
for (R=10; R<=20; R = R + 0.5)
{
A = PHASE (R, Xl, Xc); // 1. INVOCACION
cout<<"La FASE ES PHI = "<<A<<"PARA R="<<R; //5. respuesta
cout<<endl;
}
}; break;
case 3:
{
cout << "3. NOTA FINAL \n";
cout << "----------------- \n";
cout << "Ingrese la primera nota: "; cin >> nota1;
cout << "Ingrese la segunda nota: "; cin >> nota2;
cout << "Ingrese la tercera nota: "; cin >> nota3;
notafinal = NOTA_FINAL(nota1, nota2, nota3);
cout << "La nota final del estudiante es: " << notafinal << endl;
cout << endl;
}; break;
case 4:
{
cout << "4. MAYOR DE TRES NUMEROS \n";
cout << "----------------- \n";
cout << "Ingrese el valor de a: "; cin >> a;
cout << "Ingrese el valor de b: "; cin >> b;
cout << "Ingrese el valor de c: "; cin >> c;
cout << "El numero mayor es: " << mayorde(a,b,c) << endl;
}; break;
} // fin del switch
} while (Opcion!=0); // FIN DEL DO WHILE
} // FIN PROGRAMA
//-----------------------------------------------------
float IMPEDANCIA (double x, double y, double z) //3.
{
Z = sqrt (pow(x,2)+pow((y-z),2));
return Z;//4.
}
float PHASE (double p, double q, double r)
{
P = atan((q-r)/p);
return P;
}
float NOTA_FINAL (float n1, float n2, float n3)
{
notafinal = n1 * 0.3 + n2 * 0.3 + n3 * 0.4;
return notafinal;
}
int mayorde (int a, int b, int c)
{
if((a>b)&&(a>c)) return(a);
if((b>a)&&(b>c)) return(b);
if((c>a)&&(c>b)) return(c);
if((a==b)&&(b==c)){
cout << "Los 3 numeros son iguales entre si" << endl;
return(a);
}
}



