You are on page 1of 1

#include <iostream>

using namespace std;



void main()
{
double R1;
double R2;
char a;
char b;
char op;
int Rseries=0;
double Rparallel=0;
while(1)
{
{
cout<<"Enter resistor R1 value"<<endl;
cin>>R1;
cout<<"Enter resistor R2 value"<<endl;
cin>>R2;
if(R1==0){
cout<<"The resistor value R1 must not zero. Re-enter the correct
value"<<endl;
cout<<"Enter resistor R1 value"<<endl;
cin>>R1;}
if(R2==0){
cout<<"The resistor value R2 must not zero. Re-enter the correct
value"<<endl;
cout<<"Enter resistor R2 value"<<endl;
cin>>R2;}
}
{
cout<<"Please choose type of connection"<<endl;
cout<<"type a for series"<<endl;
cout<<"type b for parallel"<<endl;
cin>>op;
}
switch(op)
{
case 'a' : Rseries = R1+R2;
cout<< "Equilvalent resistance for series is "<<Rseries<<endl;
break;
case 'b' : Rparallel = (R1*R2)/(R1+R2);
cout<< "Equilvalent resistance for parallel is "<<Rparallel<<endl;
break;
default:
cout<<"Invalid operation code. Re-enter operartion code ";
break;
}
}
}

You might also like