What is the issue with my code, sorry I'm newer to programming. Also at the bottom is the header files and their corresponding source files. The issue probably has something to due with the calling the functions due to me being a beginner with that. Any advise would also be appreciated. When I try to run it the command prompt doesn't appear and some errors pop up, most of which are regarding the declaration of the functions. The errors are listed at the bottom.
#include <iostream>
#include "Circle.h"
#include "Square.h"
#include "Rectangle.h"
#include "Trapezoid.h"
using namespace std;
int main() {
int choice;
//display the menu and input the user choice
cout << "1 -- circle" << endl;
cout << "2 -- square" << endl;
cout << "3 -- rectangle" << endl;
cout << "4 -- trapezoid" << endl;
cout << "5 -- quit" << endl;
cin >> choice;
//if the user selects 5, terminate the program
if (choice == 5)
return -999;
//calculate the area based on ch, i.e. the shape chosen by the user
else if (choice == 1)
{
cout << "Radius: ";
cin >> radius;
circle();
}
else if (choice == 2)
{
cout << "Side: ";
cin >> squareSide;
squareCalc();
}
else if (choice == 3)
{
cout << "Length: ";
cin >> rectLength;
cout << "Height: ";
cin >> rectHeight;
rectangle();
}
else if (choice == 4)
{
cout << "Base1: ";
cin >> base1;
cout << "Base2: ";
cin >> base2;
cout << "Height: ";
cin >> trapHeight;
trapezoid();
}
//if the input is invalid, the menu is displayed again
else if (choice < 1 || choice > 5)
{
cout << "Invalid choice! Enter again" << endl;
main();
}
}
int circle();
double radius, circleArea;
int const pi = 3.141592;
int squareCalc();
double squareSide, squareArea;
const int numSides = 4;
int rectangle();
double rectLength, rectHeight, rectArea;
int trapezoid();
double base1, base2, trapHeight, trapArea;
#include <iostream>
#include "Circle.h"
using namespace std;
int circle()
{
circleArea = pi * radius * radius;
cout << "Area: " << circleArea << endl;
return 0;
}
#include <iostream>
#include "Square.h"
using namespace std;
int squareCalc()
{
squareArea = squareSide * numSides;
cout << "Area: " << squareArea << endl;
return 0;
}
#include <iostream>
#include "Rectangle.h"
using namespace std;
int rectangle()
{
rectArea = (rectLength * rectHeight);
cout << "Area: " << rectArea << endl;
return 0;
}
#include <iostream>
#include "Trapezoid.h"
using namespace std;
int trapeziod()
{
trapArea = 0.5 * (trapHeight) * (base1 + base2);
cout << "Area: " << trapArea << endl;
return 0;
}
error LNK2005: "double radius" (?radius@@3NA) already defined in areaCalc.obj
error LNK2005: "double circleArea" (?circleArea@@3NA) already defined in areaCalc.obj
error LNK2005: "double rectLength" (?rectLength@@3NA) already defined in areaCalc.obj
error LNK2005: "double rectHeight" (?rectHeight@@3NA) already defined in areaCalc.obj
error LNK2005: "double rectArea" (?rectArea@@3NA) already defined in areaCalc.obj
error LNK2005: "double squareSide" (?squareSide@@3NA) already defined in areaCalc.obj
error LNK2005: "double squareArea" (?squareArea@@3NA) already defined in areaCalc.obj
error LNK2005: "double base1" (?base1@@3NA) already defined in areaCalc.obj
error LNK2005: "double base2" (?base2@@3NA) already defined in areaCalc.obj
error LNK2005: "double trapHeight" (?trapHeight@@3NA) already defined in areaCalc.obj
error LNK2005: "double trapArea" (?trapArea@@3NA) already defined in areaCalc.obj
error LNK2019: unresolved external symbol "int __cdecl trapezoid(void)" (?trapezoid@@YAHXZ) referenced in function _main