#include #include using namespace std; class TotalResistance { double series_res,parallel_res,sp_res; public: TotalResistance() { series_res=parallel_res=sp_res=0; } void seriesResistance(double...


#include
#include
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:=""><><>
}
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:=""><><>
}
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:=""><><>
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////
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:=""><><>
}
void TotalCapacitance::parallelCapacitance(double capacitance[],int c)
{
for(int i=0;i<>
series_cap += capacitance[i];
cout<"total capacitance="" in="" parallel="" is:=""><><>
}
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:=""><><>
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
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:=""><><>
}
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:=""><><>
}
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:=""><><>
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main()
{
cout<"enter total="" number="" of="" resistors:="">
int n;
cin>>n;
double resistance_values[n];
cout<"enter resistances="" values:="">
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:="">
int c;
cin>>c;
double capacitance_values[c];
cout<"enter capacitance="" values:="">
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:="">
int i;
cin>>i;
double inductance_values[i];
cout<"enter inductance="" values:="">
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:=""><><>
else
cout<"time constant="" is:=""><(l><>


return 0;
}




Question


provide comments for each line of code above.

Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here