Trouble with While loop

I am writing the following program to give the area of an certain chosen geometric object. The math seems fine, however when I try to run the program it goes through Line 30, gets the input for AREA, and then it hangs at a flashing cursor, I believe it has something to do with the WHILE statement, but without the while statement, it will not loop back to the top. Does anyone have a hint that I am missing?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
  #include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;

int main()
{
    std::cout << std::fixed;
    std::cout << std::setprecision(2);

    //variable declaration
    int AREA;//type of area to solve for
    float side;//for the square
    float radius;//for the circle
    float radiussquared;//squared value of the radius
    float width;//for the rectangle
    float length;//for the rectangle
    float base;//for the triangle
    float height;//for the triangle
    float trianglearea;//Area of Triangle
    float squarearea;//Area of square
    float circlearea;//Area of circle
    float rectanglearea;//Area of rectangle
    int decider;//for deciding whether to run another loop

    //getting variable for while loop

    cout << "Please enter number for type of area to solve for (1=square, 2=circle, 3=rectangle, 4=triangle) ";
    cin >> AREA;

    decider = 1;
    while ((decider = 1));
    {
    if (( AREA == 1));
        {
            cout << "Please input the size of one of the sides of the square ";
            cin >> side;
            squarearea = side * side;
            cout << "the area of the square is " << squarearea;
            cout << "Do you wish to figure for another Area? (1 for Yes, 2 for No) ";
            cin >> decider;
            if (( decider = 2 ))
            {
               return 0;
            }
        }
    if ((AREA = 2));
        {
            cout << "Please input the radius of the circle ";
            cin >> radius;
            radiussquared = radius * radius;
            circlearea = radiussquared * M_PI;
            cout << "The area of the Circle is " << circlearea;
            cout << "Do you wish to figure for another Area? (1 for Yes, 2 for No) ";
            cin >> decider;
            if (( decider = 2 ))
            {
               return 0;
            }
        }
    if ((AREA = 3));
        {
            cout << "Please input the width of the rectangle ";
            cin >> width;
            cout << "Please input the length of the rectangle ";
            cin >> length;
            rectanglearea = width * length;
            cout << "The Area of the Rectangle is " << rectanglearea;
            cout << "Do you wish to figure for another Area? (1 for Yes, 2 for No) ";
            cin >> decider;
            if (( decider = 2 ))
            {
               return 0;
            }
        }
    if ((AREA = 4));
        {
            cout << "Please input the height of the triangle ";
            cin >> height;
            cout << "Please input the base of the triangle ";
            cin >> base;
            trianglearea = (height * base) / 2;
            cout << "The Area of the Triangle is " << trianglearea;
            cout << "Do you wish to figure for another Area? (1 for Yes, 2 for No) ";
            cin >> decider;
            if (( decider = 2 ))
            {
               return 0;
            }
        }
    }
    return 0;
}
while (decider == 1)





EDIT: Removed trailing ';'
Last edited on
a main reason for a descriptive variable name is to alleviate the need for a descriptive comment explaining the variable name...
Thank You Everyone
The same bug in most of your if conditions.
Topic archived. No new replies allowed.