Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am receiving the errors that are: IntelliSense: cannot open source file \"Capa

ID: 3644066 • Letter: I

Question

I am receiving the errors that are: IntelliSense: cannot open source file "Capacitor.h" and IntelliSense: name followed by '::' must be a class or namespace name, and Im not sure what to do can you help?

#include "Capacitor.h"
#include <conio.h>
#include <iostream>
#include <iomanip>
#include <windows.h> using namespace std;
Capacitor::Capacitor(double nom, double tol)
{
capValues[0] = nom;
capValues[1] = tol;
capValues[2] = nom * (1.0 + tol);
capValues[3] = nom * (1.0 - tol);
}
Capacitor::~Capacitor()
{
}

void Capacitor::setCapacitance(double newCapacitance)
{
capValues[0] = newCapacitance;
capValues[2] = capValues[0] * (1.0 + capValues[1]);
capValues[3] = capValues[0] * (1.0 - capValues[1]);
}
void Capacitor::setCapTolerance(double newCapTolerance)
{
capValues[1] = newCapTolerance;
capValues[2] = capValues[0] * (1.0 + capValues[1]);
capValues[3] = capValues[0] * (1.0 - capValues[1]);
}
double Capacitor::getCapacitance(void)
{
return capValues[0];
}

double Capacitor::getMinCapacitance(void)
{
return capValues[3];
}
double Capacitor::getMaxCapacitance(void)
{
return capValues[2];
}
double Capacitor::getCapTolerance(void)
{
return capValues[1];
}


// Filter.CPP
#include "Filter.h"
#include<fstream>
#include<string>
Filter::Filter(void)
{
}
Filter::~Filter(void)
{
}
void Filter::getResistor()
{
double res;
double tol;
cout<<endl<<"Enter resistor resistance: ";
cin>>res;
cout<<endl<<"Enter resistor tolerance : ";
cin>>tol;
resistor.setResistance(res);
resistor.setResTolerance(tol);
}
void Filter::getCapacitor()
{
double cap;
double tol;
cout<<endl<<"Enter capacitor capacitance: ";
cin>>cap;
cout<<endl<<"Enter capacitor tolerance : ";
cin>>tol;
capacitor.setCapacitance(cap);
capacitor.setCapTolerance(tol);
}
void Filter::getFilterType()
{
string type;
cout<<endl<<"Enter Filter type(Low, High) : ";
cin>>type;
filterType=type;
}
void Filter::calculateFrequency()
{
cutOffFrequency=1/(2*3.14*(resistor.getResistance()*capacitor.getCapacitance()));
maxFrequency=1/(2*3.14*(resistor.getResistance()+resistor.getResTolerance())*(capacitor.getCapacitance()+capacitor.getCapTolerance()));

minFrequency=1/(2*3.14*(resistor.getResistance()-resistor.getResTolerance())*(capacitor.getCapacitance()-capacitor.getCapTolerance()));
}
double Filter::getCutoffFrequency()
{
return cutOffFrequency;
}
double Filter::getMaxFrequency()
{
return maxFrequency;
}
double Filter::getMinFrequency()
{
return minFrequency;
}
void Filter::writeToFile()
{
string filename;
cout<<"Enter file name: ";
cin>>filename;
ofstream fout;
fout.open(filename);
fout<<"Resistor resistance: "<<resistor.getResistance();
fout<<endl<<"Resistor tolerance: "<<resistor.getResTolerance();
fout<<endl<<"Resistor Min resistance: "<<resistor.getMinResistance();
fout<<endl<<"Resistor Max resistance: "<<resistor.getMaxResistance();
fout<<endl<<"Capacitor capacitance: "<<capacitor.getCapacitance();
fout<<endl<<"Capacitor tolerance: "<<capacitor.getCapTolerance();
fout<<endl<<"Capacitor max capacitance: "<<capacitor.getMaxCapacitance();
fout<<endl<<"Capacitor min capacitance: "<<capacitor.getMinCapacitance();
fout<<endl<<"Cut off frequency: "<<cutOffFrequency;
fout<<endl<<"Max frequency: "<<maxFrequency;
fout<<endl<<"Min frequency: "<<minFrequency;
fout<<endl<<"Filter Type: "<<filterType;
fout.close();
}
void Filter::readFromFile(string filename)
{
ifstream fin;
fin.open(filename);
if(!fin)
{
cout<<"File do not exist.";
return;
}
else
{
string line;
while(fin)
{
getline(fin,line);
cout<<line<<endl;
}
}
fin.close();
}

// Resistor.CPP
#include "Resistor.h"
#include <conio.h>
#include <iostream>
#include <iomanip>
#include "Resistor.h"
#include <windows.h>
using namespace std;
Resistor::Resistor(double nom, double tol)
{
resValues[0] = nom;
resValues[1] = tol;
resValues[2] = nom * (1.0 + tol);
resValues[3] = nom * (1.0 - tol);
}
Resistor::~Resistor()
{
}
void Resistor::setResistance(double newResistance)
{
resValues[0] = newResistance;
resValues[2] = resValues[0] * (1.0 - resValues[1]);
resValues[3] = resValues[0] * (1.0 + resValues[1]);
}
void Resistor::setResTolerance(double newResTolerance)
{
resValues[1] = newResTolerance;
resValues[2] = resValues[0] * (1.0 - resValues[1]);
resValues[3] = resValues[0] * (1.0 + resValues[1]);
}
double Resistor::getResistance(void)
{
return resValues[0];
}

double Resistor::getMinResistance(void)
{
return resValues[3];
}
double Resistor::getMaxResistance(void)
{
return resValues[2];
}
double Resistor::getResTolerance(void)
{
return resValues[1];
}


// MAin.cpp

#include "Filter.h"
#include<string>
int main()
{
Filter f;
f.getResistor();
f.getCapacitor();
f.getFilterType();
f.calculateFrequency();
f.writeToFile();
string filename;
cout<<"Enter file name to read values: ";
cin>>filename;
f.readFromFile(filename);
system("pause");
return 0;
}

Explanation / Answer

#ifndef complex_2 #define complex_2 #include #include using namespace std; namespace comp { class complex{ protected: double re, im; public: complex(){re = im = 0;} complex(double re_in, double im_in){ re = re_in; im = im_in; } ~complex(){} void set_re(double re_in){ re = re_in; } void set_im(double im_in){ im = im_in; } double get_re() const{ return re; } double get_im() const{ return im; } complex comp_conj() const{ complex temp; temp.set_re(re); temp.set_im(-im); return temp; } complex operator + (const complex &c)const{ complex temp(re + c.get_re(), im + c.get_im()); return temp; } complex operator - (const complex &c)const{ complex temp(re - c.get_re(), im - c.get_im()); return temp; } complex operator * (const complex &c1)const{ complex temp; double a(re), b(im), c(c1.get_re()), d(c1.get_im()); temp.set_re(a*c - b*d); temp.set_im(b*c + a*d); return temp; } complex operator / (const complex &c1)const{ complex temp; double a(re), b(im), c(c1.get_re()), d(c1.get_im()); temp.set_re((a*c + b*d)/(pow(c,2) + pow(d,2))); temp.set_im((b*d - a*d)/(pow(c,2) + pow(d,2))); return temp; } double mod() const{ return(sqrt(pow(re,2) + pow(im,2))); } double arg() const{ return(atan(im/re)); } friend ostream & operator
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote