using namespace std;
class TotalResistance
{
double series_res,parallel_res,sp_res;
public:
TotalResistance()
{
series_res=parallel_res=sp_res=0;
}
void seriesResistance(double resistance[],int n);
void parallelResistance(double resistance[],int n);
void spResistance(double resistance[],int n);
};
void TotalResistance::seriesResistance(double resistance[],int n)
{
for(int i=0;i<>
series_res += resistance[i];
cout<"total resistance="" in="" series="" is:="">"total><><>
}
void TotalResistance::parallelResistance(double resistance[],int n)
{
double temp=0;
for(int i=0;i<>
temp += (1/resistance[i]);
parallel_res = 1/temp;
cout<"total resistance="" in="" parallel="" is:="">"total><><>
}
void TotalResistance::spResistance(double resistance[],int n)
{
for(int i=0;i<>
series_res += resistance[i];
double temp=0;
for(int i=0;i<>
temp += (1/resistance[i]);
parallel_res = 1/temp;
cout<"total resistance="" in="" series="" parallel="" is:="">"total><><>
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TotalCapacitance
{
double series_cap,parallel_cap,sp_cap;
public:
TotalCapacitance()
{
series_cap=parallel_cap=sp_cap=0;
}
void seriesCapacitance(double capacitance[],int c);
void parallelCapacitance(double capacitance[],int c);
void spCapacitance(double capacitance[],int c);
};
void TotalCapacitance::seriesCapacitance(double capacitance[],int c)
{
double temp=0;
for(int i=0;i<>
temp += (1/capacitance[i]);
parallel_cap = 1/temp;
cout<"total capacitance="" in="" series="" is:="">"total><><>
}
void TotalCapacitance::parallelCapacitance(double capacitance[],int c)
{
for(int i=0;i<>
series_cap += capacitance[i];
cout<"total capacitance="" in="" parallel="" is:="">"total><><>
}
void TotalCapacitance::spCapacitance(double capacitance[],int c)
{
double temp=0;
for(int i=0;i<>
temp += (1/capacitance[i]);
parallel_cap = 1/temp;
for(int i=0;i<>
series_cap += capacitance[i];
cout<"total capacitance="" in="" series="" parallel="" is:="">"total><><>
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TotalInductance
{
double series_ind,parallel_ind,sp_ind;
public:
TotalInductance()
{
series_ind=parallel_ind=sp_ind=0;
}
void seriesInductance(double inductance[],int id);
void parallelInductance(double inductance[],int id);
void spInductance(double inductance[],int id);
};
void TotalInductance::seriesInductance(double inductance[],int id)
{
for(int i=0;i<>
series_ind += inductance[i];
cout<"total inductance="" in="" series="" is:="">"total><><>
}
void TotalInductance::parallelInductance(double inductance[],int id)
{
double temp=0;
for(int i=0;i<>
temp += (1/inductance[i]);
parallel_ind = 1/temp;
cout<"total inductance="" in="" parallel="" is:="">"total><><>
}
void TotalInductance::spInductance(double inductance[],int id)
{
for(int i=0;i<>
series_ind += inductance[i];
double temp=0;
for(int i=0;i<>
temp += (1/inductance[i]);
parallel_ind = 1/temp;
cout<"total resistance="" in="" series="" parallel="" is:="">"total><><>
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
cout<"enter total="" number="" of="" resistors:="">"enter>
int n;
cin>>n;
double resistance_values[n];
cout<"enter resistances="" values:="">"enter>
for(int i=0;i<>
cin>>resistance_values[i];
TotalResistance robj;
robj.seriesResistance(resistance_values,n);
robj.parallelResistance(resistance_values,n);
robj.spResistance(resistance_values,n);
/////////////////////////////////////////////
cout<"enter total="" number="" of="" capacitors:="">"enter>
int c;
cin>>c;
double capacitance_values[c];
cout<"enter capacitance="" values:="">"enter>
for(int i=0;i<>
cin>>capacitance_values[i];
TotalCapacitance cobj;
cobj.seriesCapacitance(capacitance_values,c);
cobj.parallelCapacitance(capacitance_values,c);
cobj.spCapacitance(capacitance_values,c);
/////////////////////////////////////////////
cout<"enter total="" number="" of="" inductors:="">"enter>
int i;
cin>>i;
double inductance_values[i];
cout<"enter inductance="" values:="">"enter>
for(int j=0;jcin>>inductance_values[j];
TotalInductance iobj;
iobj.seriesInductance(inductance_values,i);
iobj.parallelInductance(inductance_values,i);
iobj.spInductance(inductance_values,i);
int R,L,C;
cout<"in order="" to="" find="" terminal="" voltage:="" enter="" the="" values="" of="" \n--=""> Effective Resistance: R\n";
cin>>R;
cout<"-->Enter Effective Capacitance: C or Effective Inductance: L (select 'C' or 'L') \n";
char ch;
cin>>ch;
int flag=0;
if(ch=='c' || ch=='C')
{
flag=1;
cin>>C;
}
else
cin>>L;
if(flag==1)
cout<"time constant="" is:="">"time><><>
else
cout<"time constant="" is:="">"time><(l>(l><>
return 0;
}
Question
provide comments for each line of code above.
"-->"in>