NEED HELP WITH PROGRAM in C++ USING FUNCTIONS

I have this program and I need to add a few things to it.

The criteria is:

Create a function that only prints out the Menu. Remember to use the
correct return type for this type of function.

Create a function to handle the Area of a Circle. This includes the data input, validation, and calculation. The function should return the area of the circle, so use the correct return type for this function. The output of the area will be handled in the main function once this function returns the result.

Create a function to handle the Area of a Rectangle. This includes the data input, validation, and calculation. The function should return the area of the rectangle, so use the correct return type for this function. The output of the area will be handled in the main function once this function returns the result.

Create a function to handle the Area of a Triangle. This includes the data input, validation, and calculation. The function should return the area of the triangle, so use the correct return type for this function. The output of the area will be handled in the main function once this function returns the result.

Since we know how loops work, loop until the user enters a valid input when validating the inputs.

I did some of it, but I am having trouble with other parts. Here is what I have so far:

#include <iostream>
#include <iomanip>
using namespace std;

int main()

{
int choice;
int area;
double radius, length, width, height, base;

// User picks a shape

cout << "Welcome to the geometry calculator."<< endl;

cout << "Please pick a shape:" << endl;

cout << "Enter 1 for the area of a circle" << endl;

cout << "Enter 2 for the area of a rectangle" << endl;

cout << "Enter 3 for the area of a triangle" << endl;

cout << "Enter 4 to quit" << endl;

cout << "Enter your choice of 1-4:" << endl;
cin >> choice;

cout << fixed << setprecision(2);


// If user chooses circle (1), prompt user for radius
if (choice == 1)

{cout << "Enter radius: " << endl;
cin >> radius; }

if (radius < 0)

{cout << "Radius cannot be negative" << endl;
cout << "Enter radius again:" << endl;
cin >> radius; }


//Calculate area of a the circle
{ area = radius * (3.14 * 3.14);
cout << "The area of the circle is: " << area << endl;}

// If user chooses a rectangle (2), prompt user for length and width
if (choice == 2)
{ cout << "Enter length: " << endl;
cin >> length;
cout << "Enter width: " << endl;
cin >> width; }

if(length < 0)

{cout << "Length cannot be less than 0" << endl;
cout << "Enter length again: \n";
cin >> length; }

if(width < 0)

{cout << "Width cannot be less than 0" << endl;
cout << "Enter width again: "<< endl;
cin >> width;
}


// Calculate area of the rectangle
{
area = length * width;
cout << "The area of the rectangle is: " << area << endl;
}


// If the user chooses a triangle (3), prompt the user for base and height
if (choice == 3)
{
cout << "Enter base length: " << endl;
cin >> base;
cout << "Enter height: " << endl;
cin >> height;
}

if(base < 0)
{
cout << "Base cannot be less than 0" << endl;
cout << "Enter base again: " << endl;
cin >> base;
}

if(height < 0)
{
cout << "Height cannot be less than 0" << endl;
cout << "Enter height again: " << endl;
cin >> height;
}

// Calculate the area of the triangle
{
area = base * height * 0.5;
cout << "The area of the triangle is: " << area << endl;
}

// If the user choose quit (4), end the program
if (choice == 4)

{cout << "No choice selected, end of program." << endl;}


}

Any input is appreciated.
Topic archived. No new replies allowed.