EVAP 4: RESISTENCIAS(WHILE)

             


#include <iostream>
#include <math.h>
using namespace std;

int main()
{

int opcion;
cout<<"********MENU PRINCIPAL********";
cout<<"\n";
cout<<"OPCION 1: RESISTENCIA EN SERIE \n";
cout<<"OPCION 2: RESISTENCIA EN PARALELO \n";

cout<<"**************\n";
cout<<"INGRESE UNA OPCION";
cout<<"\n"; cin>>opcion;
switch(opcion)
{
case 1:
{ cout<<"*****RESISTENCIA EN SERIE*****";
cout<<"\n";
float R, REQ;
char SN;
cout<<"DESEA INGRESAR UNA RESISTENCIA : "; cin>>SN;

REQ=0; //neutro aditivo
while(SN=='S')
{cout<<"INGRESE LA RESISTENCIA: "; cin>>R;
REQ=REQ+R;

cout<<"DESEA INGRESAR OTRA RESISTENCIA :";cin>>SN;
}

//fin del while
cout<<"LA RESISTENCIA EQUIVALENTE ES : ";cout<<REQ;
}
break;

case 2:
{ cout<<"*****RESISTENCIA EN PARALELO*****";
cout<<"\n";
float R, REQ, REQF;
char SN;
cout<<"DESEA INGRESAR UNA RESISTENCIA : "; cin>>SN;

REQ=0; //neutro aditivo
while(SN=='S')
{cout<<"INGRESE LA RESISTENCIA: "; cin>>R;
REQ=REQ+1/R;
REQF=pow(REQ,-1);

cout<<"DESEA INGRESAR OTRA RESISTENCIA :";cin>>SN;
}

//fin del while
cout<<"LA RESISTENCIA EQUIVALENTE ES : ";cout<<REQF; 

}
break;

}

cout<<"\n";
system("pause");
return 0;
} // FIN DEL PROGAMA 
 

No hay comentarios:

Publicar un comentario