1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

#include <iostream> //use of cin & cout
#include <iomanip> // manipulate decimals/cout
#include <cmath> // math functions
using namespace std;
double pi = acos(1.0);
void Accircuit (double,double,double,double,double,double,double&,double&,
double&,double&,double&)
int main()
{
double R,L,C,E,f_initial,f_final,f,X_L,X_C,Z,I;
char Answer;
// cout << "Hi this program will";
do
{
cout << "Please enter R(Resistance in \352): ";
cin >> R;
cout << "\nEnter a value for L(Inductance in Henries): ";
cin >> L;
cout << "\nEnter a value for C(Capacitance in Farads): ";
cin >> C;
cout << "\nEnter a value for E(Volts): ";
cin >> E;
cout << "\nEnter a value for initial Frequency: ";
cin >> f_initial;
cout << "\nEnter a value for final Frequency: ";
cin >> f_final;
system("pause");
system("CLS");
Accircuit (R,L,C,E,f_initial,f_final,f,X_C,X_L,Z,I);
cout << "Freq(Hz) XC(\352) XL(\352) Z(\352) I(mA)\n"
<< "    \n";
cout << f << " "<< setw(14)<< setprecision(6) << X_C << " "<<setw(8)
<< setprecision(3) <<
X_L << " " << setw(8) << setprecision(6) << Z << " " << setw(5) <<
setprecision(3) << I << endl;
cout << "Would you like to run the program again? (Enter Y or N): ";
cin >> Answer;
system("pause");
system("CLS");
}
while (Answer == 'Y'  Answer == 'y');
}
void Accircuit(double R,double L,double C,double E,double fi,double ff,
double& f,double& X_C,
double& X_L,double& Z,double& I)
{
f = fi;
X_C = 1/(2*pi*f*(C/1000000));
X_L = 2*pi*f*(L/1000);
Z = sqrt((R*R)+((X_L+X_C)*(X_L+X_C)));
I = E/Z*1000;
}
 