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

I am recieving errors of IntelliSense: the #if for this directive is missing and

ID: 3645509 • Letter: I

Question

I am recieving errors of IntelliSense: the #if for this directive is missing and error C1083: Cannot open include file: 'Shape.h': No such file or directory...IntelliSense: cannot open source file "Circle.h".. This is the error that i am recieivng with Shape.h , rectangle.h..



#ifndef ShapeH
#define ShapeH

class Shape
{
public:
virtual double Area() const = 0;
virtual double Parimeter() const = 0;
private:
};

#endif

//Circle.h

#include "Shape.h"

class Circle: public Shape
{
public:
Circle();
void setRadius(const double r);
double getRadius() const;
virtual double Area() const;
virtual double Parimeter() const;
~Circle();
protected:
double Radius;
};

#endif

//Circle.cpp

#include <iostream>
#include "Circle.h"

using namespace std;

const double PI = 3.14159;

Circle::Circle()
{
}

void Circle::setRadius(const double r)
{
Radius = r;
}

double Circle::getRadius() const
{
return(Radius);
}

double Circle::Area() const
{
return (PI * Radius * Radius);
}

double Circle::Parimeter() const
{
return(2 * PI * Radius);
}

Circle::~Circle()
{
}

//Rectangle.h

#ifndef RectangleH
#define RectangleH
#include "Shape.h"

class Rectangle: public Shape
{
public:
Rectangle();
void setDimensions(int H, int W);
double getHeight();
double getWidth();
double Area() const;
double Parimeter() const;
~Rectangle();
private:
double Height;
double Width;
double A;
double P;
};

#endif

//Rectangle.cpp

#include <iostream>
#include "Rectangle.h"

using namespace std;

Rectangle::Rectangle()
{
}

void Rectangle::setDimensions(int W, int H)
{
Width = W;
Height = H;
}

double Rectangle::getHeight()
{
return(Height);
}

double Rectangle::getWidth()
{
return(Width);
}

double Rectangle::Area() const
{
return(Width * Height);
}

double Rectangle::Parimeter() const
{
return((2 * Width) + (2 * Height));
}

Rectangle::~Rectangle()
{
}

//Main.cpp

#include <iostream>
#include "Circle.h"
#include "Rectangle.h"

using namespace std;

//Prototype
void displayMenu(void);
char getMenuSelection(void);
void Cir(void);
void Rec(void);

void main()
{
char action;
double r;
double h;
double w;
Rectangle rec;
Circle cir;

do
{
displayMenu(); //displays the intitial menu
action = getMenuSelection(); //gets the menu selection
if(action == 'c' || action == 'C')
{
cout << "Enter the radius of the circle: ";
cin >> r;
cir.setRadius(r);
cout << "Radius: " << r << endl;
cout << "Area: " << cir.Area() << endl;
cout << "Parimeter: " << cir.Parimeter() << endl;
}
if(action == 'r' || action == 'R')
{
cout << "Enter the height of the rectangle: ";
cin >> h;
cout << "Enter the length of the rectangle: ";
cin >> w;
rec.setDimensions(h, w);
cout << "Dimensions= " << "Hight: " << h << " Width: " << w << endl;
cout << "Area: " << rec.Area() << endl;
cout << "Parimeter: " << rec.Parimeter() << endl;
}
if(action == 'l' || action == 'L')
{
}
}
while(action != 'q' || action != 'Q'); //loop until program has been quit
cin.ignore(2);
}

void displayMenu() //Displays the initial starting menu options
{
cout << "==================================================================" << endl;
cout << "|*************** Enter C to create a circle object **************|" << endl;
cout << "==================================================================" << endl;
cout << "|************** Enter R to create a rectangle object ************|" << endl;
cout << "==================================================================" << endl;
cout << "|****************** Enter L to print array list *****************|" << endl;
cout << "==================================================================" << endl;
cout << "|*********************** Enter Q To quit ************************|" << endl;
cout << "==================================================================" << endl;
}

char getMenuSelection() //Gets the menu selection
{
cout << "Enter your choice and press enter:";
char action;
cin >> action;

switch(action)
{
case 'c':
case 'C':
return action;
break;
case 'r':
case 'R':
return action;
break;
case 'l':
case 'L':
return action;
break;
case 'q':
case 'Q':
exit(0);
break;
default: //if menu selection is not valid let the user know
cout << " Invalid selection: try again" << endl;
displayMenu();
getMenuSelection();
break;

}
}//Shape.c

#ifndef ShapeH
#define ShapeH

class Shape
{
public:
virtual double Area() const = 0;
virtual double Parimeter() const = 0;
private:
};

#endif

//Circle.h

#include "Shape.h"

class Circle: public Shape
{
public:
Circle();
void setRadius(const double r);
double getRadius() const;
virtual double Area() const;
virtual double Parimeter() const;
~Circle();
protected:
double Radius;
};

#endif

//Circle.cpp

#include <iostream>
#include "Circle.h"

using namespace std;

const double PI = 3.14159;

Circle::Circle()
{
}

void Circle::setRadius(const double r)
{
Radius = r;
}

double Circle::getRadius() const
{
return(Radius);
}

double Circle::Area() const
{
return (PI * Radius * Radius);
}

double Circle::Parimeter() const
{
return(2 * PI * Radius);
}

Circle::~Circle()
{
}

//Rectangle.h

#ifndef RectangleH
#define RectangleH
#include "Shape.h"

class Rectangle: public Shape
{
public:
Rectangle();
void setDimensions(int H, int W);
double getHeight();
double getWidth();
double Area() const;
double Parimeter() const;
~Rectangle();
private:
double Height;
double Width;
double A;
double P;
};

#endif

//Rectangle.cpp

#include <iostream>
#include "Rectangle.h"

using namespace std;

Rectangle::Rectangle()
{
}

void Rectangle::setDimensions(int W, int H)
{
Width = W;
Height = H;
}

double Rectangle::getHeight()
{
return(Height);
}

double Rectangle::getWidth()
{
return(Width);
}

double Rectangle::Area() const
{
return(Width * Height);
}

double Rectangle::Parimeter() const
{
return((2 * Width) + (2 * Height));
}

Rectangle::~Rectangle()
{
}

//Main.cpp

#include <iostream>
#include "Circle.h"
#include "Rectangle.h"

using namespace std;

//Prototype
void displayMenu(void);
char getMenuSelection(void);
void Cir(void);
void Rec(void);

void main()
{
char action;
double r;
double h;
double w;
Rectangle rec;
Circle cir;

do
{
displayMenu(); //displays the intitial menu
action = getMenuSelection(); //gets the menu selection
if(action == 'c' || action == 'C')
{
cout << "Enter the radius of the circle: ";
cin >> r;
cir.setRadius(r);
cout << "Radius: " << r << endl;
cout << "Area: " << cir.Area() << endl;
cout << "Parimeter: " << cir.Parimeter() << endl;
}
if(action == 'r' || action == 'R')
{
cout << "Enter the height of the rectangle: ";
cin >> h;
cout << "Enter the length of the rectangle: ";
cin >> w;
rec.setDimensions(h, w);
cout << "Dimensions= " << "Hight: " << h << " Width: " << w << endl;
cout << "Area: " << rec.Area() << endl;
cout << "Parimeter: " << rec.Parimeter() << endl;
}
if(action == 'l' || action == 'L')
{
}
}
while(action != 'q' || action != 'Q'); //loop until program has been quit
cin.ignore(2);
}

void displayMenu() //Displays the initial starting menu options
{
cout << "==================================================================" << endl;
cout << "|*************** Enter C to create a circle object **************|" << endl;
cout << "==================================================================" << endl;
cout << "|************** Enter R to create a rectangle object ************|" << endl;
cout << "==================================================================" << endl;
cout << "|****************** Enter L to print array list *****************|" << endl;
cout << "==================================================================" << endl;
cout << "|*********************** Enter Q To quit ************************|" << endl;
cout << "==================================================================" << endl;
}

char getMenuSelection() //Gets the menu selection
{
cout << "Enter your choice and press enter:";
char action;
cin >> action;

switch(action)
{
case 'c':
case 'C':
return action;
break;
case 'r':
case 'R':
return action;
break;
case 'l':
case 'L':
return action;
break;
case 'q':
case 'Q':
exit(0);
break;
default: //if menu selection is not valid let the user know
cout << " Invalid selection: try again" << endl;
displayMenu();
getMenuSelection();
break;

}
}

Explanation / Answer

I think your problem is in declaring the preprocessor directive. I've copied your code and minus one error in my compiler ("main must return int") the code works beautifully(minus the arraylist option). Please copy the files I've rewritten below:

IN A FILE NAMED "Shape.h":

#ifndef SHAPE_H
#define SHAPE_H

class Shape
{
public:
virtual double Area() const = 0;
virtual double Parimeter() const = 0;
private:
};

#endif

IN A FILE NAMED "Circle.h":

#ifndef CIRCLE_H
#define CIRCLE_H
#include "Shape.h"

class Circle: public Shape
{
public:
Circle();
void setRadius(const double r);
double getRadius() const;
virtual double Area() const;
virtual double Parimeter() const;
~Circle();
protected:
double Radius;
};

#endif

IN A FILE NAMED "Circle.cpp":

#include <iostream>
#include "Circle.h"

using namespace std;

const double PI = 3.14159;

Circle::Circle()
{
}

void Circle::setRadius(const double r)
{
Radius = r;
}

double Circle::getRadius() const
{
return(Radius);
}

double Circle::Area() const
{
return (PI * Radius * Radius);
}

double Circle::Parimeter() const
{
return(2 * PI * Radius);
}

Circle::~Circle()
{
}

IN A FILE NAMED "Rectangle.h":

#ifndef RECTANGLE_H
#define RECTANGLE_H
#include "Shape.h"

class Rectangle: public Shape
{
public:
Rectangle();
void setDimensions(int H, int W);
double getHeight();
double getWidth();
double Area() const;
double Parimeter() const;
~Rectangle();
private:
double Height;
double Width;
double A;
double P;
};

#endif

IN A FILE NAMED: "Rectangle.cpp":

#include <iostream>
#include "Rectangle.h"

using namespace std;

Rectangle::Rectangle()
{
}

void Rectangle::setDimensions(int W, int H)
{
Width = W;
Height = H;
}

double Rectangle::getHeight()
{
return(Height);
}

double Rectangle::getWidth()
{
return(Width);
}

double Rectangle::Area() const
{
return(Width * Height);
}

double Rectangle::Parimeter() const
{
return((2 * Width) + (2 * Height));
}

Rectangle::~Rectangle()
{
}

IN A FILE NAMED: "main.cpp":

//Main.cpp

#include <iostream>
#include "Circle.h"
#include "Rectangle.h"

using namespace std;

//Prototype
void displayMenu(void);
char getMenuSelection(void);
void Cir(void);
void Rec(void);

int main()
{
char action;
double r;
double h;
double w;
Rectangle rec;
Circle cir;

do
{
displayMenu(); //displays the intitial menu
action = getMenuSelection(); //gets the menu selection
if(action == 'c' || action == 'C')
{
cout << "Enter the radius of the circle: ";
cin >> r;
cir.setRadius(r);
cout << "Radius: " << r << endl;
cout << "Area: " << cir.Area() << endl;
cout << "Parimeter: " << cir.Parimeter() << endl;
}
if(action == 'r' || action == 'R')
{
cout << "Enter the height of the rectangle: ";
cin >> h;
cout << "Enter the length of the rectangle: ";
cin >> w;
rec.setDimensions(h, w);
cout << "Dimensions= " << "Hight: " << h << " Width: " << w << endl;
cout << "Area: " << rec.Area() << endl;
cout << "Parimeter: " << rec.Parimeter() << endl;
}
if(action == 'l' || action == 'L')
{
}
}
while(action != 'q' || action != 'Q'); //loop until program has been quit
cin.ignore(2);
}

void displayMenu() //Displays the initial starting menu options
{
cout << "==================================================================" << endl;
cout << "|*************** Enter C to create a circle object **************|" << endl;
cout << "==================================================================" << endl;
cout << "|************** Enter R to create a rectangle object ************|" << endl;
cout << "==================================================================" << endl;
cout << "|****************** Enter L to print array list *****************|" << endl;
cout << "==================================================================" << endl;
cout << "|*********************** Enter Q To quit ************************|" << endl;
cout << "==================================================================" << endl;
}

char getMenuSelection() //Gets the menu selection
{
cout << "Enter your choice and press enter:";
char action;
cin >> action;

switch(action)
{
case 'c':
case 'C':
return action;
break;
case 'r':
case 'R':
return action;
break;
case 'l':
case 'L':
return action;
break;
case 'q':
case 'Q':
exit(0);
break;
default: //if menu selection is not valid let the user know
cout << " Invalid selection: try again" << endl;
displayMenu();
getMenuSelection();
break;

}

return 0;
}

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