You, My friend deserve a Knighthood! the program is running! I will post you my working code now, theres a few bits of tidying to do but if you wanna give it the once over to check what ive done is correct that would be very helpful indeed.
Code:
//Header file for RLC Series CIrcuit
//Created by Daniel Jackson
#include <iostream>
using namespace std;
class RLC_Series_Cct
{
public:
void Incrementloop(double Resistance, double Capacitance, double Inductance, double MinFreq, double MaxFreq, double VS);
private:
double actualFreq;
double Z;
double I;
double VR;
double NF;
double XL;
double XC;
double VOVR;
int iteration;
int Maxstep;
};
Code:
//RLC Series Circuit C++ File
//Created by Daniel Jackson
#include <iostream>
#include <iomanip>
using namespace std;
#include <cmath>
using std::pow;
using std::log;
using std::setprecision;
#include <string>
using std::string;
using std::getline;
#include "Simulation.h"
#include "RLCSeriesCircuit.h"
const double pi = 3.1415926535; //Global constant
void RLC_Series_Cct::Incrementloop(double Resistance,double Capacitance, double Inductance, double MinFreq, double MaxFreq, double VS) //2nd function (calculation with for loop)
{
cout << right; // one time exectution
cout.fill ('*');
NF = (((2*pi*sqrt(Inductance*Capacitance))/1)); //Calculate Natural Frequency
Maxstep = ((log10(MaxFreq) - log10(MinFreq))/(0.1)); //incerement calculation
cout << "Voltage ratio plot at each frequency step:\n\n"; //introduces chart
for (iteration= 1; iteration<= Maxstep; iteration++) //for loop begins
{
actualFreq = (MinFreq * pow(10.0, (0.1 * iteration))); // plot Voltage ratio
XL = (2 * pi * actualFreq * Inductance); //Calculation
XC = (1/ (2 * pi * actualFreq * Capacitance)); //Calculation
Z = (sqrt(Resistance * Resistance + (XL - XC) * (XL - XC))); //Calculation
I = (VS / Z); //Calculation
VR = (I * Resistance); //Calculation
VOVR = (VR / VS); //Calculation
cout << setw(VOVR * 100) << actualFreq << setprecision (2) << endl;
}
cout << "\nNatural frequency of circuit = " << NF << setprecision( 2 ); //outputs Natural Frequency to user
}
So ive added in all the variables and it seems to work, i cant believe something this simple has given me such a headache...spose its easy when you know how though.