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

Hi, I have another code lab question. Please, make the program easy to understan

ID: 3666492 • Letter: H

Question

Hi, I have another code lab question. Please, make the program easy to understand if possible and please follow requirements. Thank you so much.

4.21: Geometry Calculator

Write a program that displays the following menu:



Geometry Calculator

1. Calculate the Area of a Circle

2. Calculate the Area of a Rectangle

3. Calculate the Area of a Triangle

4. Quit

Enter your choice (1-4):


If the user enters 1, the program should ask for the radius of
the circle and then display its area. Use the following formula:

area = (the square of r)

Use 3.14159 for and the radius of the circle for r.


If the user enters 2, the program should ask for the length and
width of the rectangle and then display the rectangle’s area.
Use the following formula:

area = length * width

If the user enters 3, the program should ask for the length of
the triangle’s base and its height, and then display its area.
Use the following formula:

area = base * height * .5

If the user enters 4, the program should end.


Input Validation: Display an error message if the user enters a
number outside the range of 1 through 4 when selecting an item
from the menu. Do not accept negative values for the circle’s
radius, the rectangle’s length or width, or the triangle’s base
or height.


NOTE:
If the user enters an improper menu choice (1-4), the program prints
"The valid choices are 1 through 4. Run the program again and select one of those."


If the user enters a negative radius, the program prints "The radius can not be less than zero."


If the user enters a negative value for height or base , the program prints "Only enter positive values for base and height."

SAMPLE RUN #1: ./ETest

Instructor Notes:

Here are all of the output strings necessary to help you with this assignment.

Explanation / Answer

#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;
int main()
{
    int rectangle_area, radius, area, width, length, height;
    float circle_area, triangle_area;
    const double PI = 3.14;
    cout << "enter 1 for the radius circle" << endl;
    cout << "Enter 2 for the width of the rectangle" << endl;
    cout << "Enter 3 for the lenght of the triangle" << endl;
    cout << "Enter 4 for the program to quit" <<endl;


    while (1==1)
    {
        cout << "Choose Your option : ";
        cin >> area;
        cout << endl;

        switch (area)
       {
            case 1:
                cout << "enter the radius of a circle ";
                cin >> radious;
                cout << " enter the area of a circle. ";
                circle_area= PI * radius * radious;
                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 rectangl" << 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;

            break;

            case 4:
                cout << "program quit" << endl;
                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