Hello, I'm having a little issue with my program, the assignment is to create a Geometric Calculator using Functions. I tried doing function "void menu" but can't get it to work, I know it's a very little error I'm not spotting in the program correctly tried tracing but couldn't find the issue. Trying to do a very simple program done this before but with no use of functions. Any help will be highly appreciated!!! Thank you!!!!
int rectangle_area, radius, area,repeat, width, length, height;
float circle_area, triangle_area;
const double PI = 3.14;
int main()
{
cout << "Enter 1 for the radius circle." << endl;
cout << "Enter 2 for the width of the rectangle." << endl;
cout << "Enter 3 for the length of the triangle." << endl;
cout << "Enter 4 for the program to quit." <<endl;
}
void Menu()
{
if (1==1)
{
cout << "Choose Your option: ";
cin >> area;
cout << endl;
switch (area)
{
case 1:
cout << "Enter the radius of a circle: " << endl;
cin >> radius;
cout << " Enter the area of a circle: " << endl;
circle_area= PI * radius * radius;
cout << "Area of the circle is: " << circle_area << endl;
break;
case 2:
cout << "Enter the width of a rectangle: "<< endl;
cin >> width;
cout << "Enter the length of the rectangle: " << endl;
cin >> length;
cout << "Enter the area of the rectangle: " << endl;
rectangle_area = width*length;
cout << "Rectangular Area: " << triangle_area << endl;
break;
case 3:
cout << "Enter the length of a triangle" << endl;
cin >> length;
cout << "Enter the height of a triangle" << endl;
cin >> height;
triangle_area = length * height /2;
cout << "Triangle Area: " << triangle_area << endl;
cout << "program quit" << endl;
break;
case 4:
cout << "-☢️WARNING!WARNING!☢️-Command Activated\nProgram Closed📴" << endl;
This is your main function, the starting point of your program:
1 2 3 4 5 6 7
int main()
{
cout << "Enter 1 for the radius circle." << endl;
cout << "Enter 2 for the width of the rectangle." << endl;
cout << "Enter 3 for the length of the triangle." << endl;
cout << "Enter 4 for the program to quit." <<endl;
}
If you want to call Menu, you have to call it through the main function.
void Menu()
{
if (1==1) /// why?
{
// ...
The if statement was when I was starting to use If's again thought it was gonna do an effect in the program for the menu at first. I removed it from the program it's working great!
"If you want to call Menu, you have to call it through the main function.
" Thank you it helped me figure out what I wasn't viewing throughout my tracing.