Help with program please

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
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    float A, G, V, Q;
    const float SENTINEL = Q; //type to stop the loop
    float length, width, depth;
    char number;
    
    cout << "Enter numbers for Surface Area(A), Girth(G), and Volume(V). To stop the loop, enter Q." << endl;
     cin >> number;
     while(number != SENTINEL)
     
     if (number == A)
        A = 2*length*width + 2*width*depth + 2*length*width;
     else if (number == G)
        G = 2*(length*width) + depth;
     else if (number == V)
        V = length * width * depth;
        
     cout << "Continue\n";
     cin >> number;
     
    
    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         << setprecision(2)
         << "The surface area is " << A << endl;

    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         << setprecision(2)
         << "The girth+depth is " << G << endl;
         
    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         <<setprecision(2)
         << "The volume is " << V << endl;



system("pause");
return 0;

}


At the moment, thats the program I created. Apparently it wouldn't do what I want it to do.
1) To calculate the "Surface Area", "Volume", and/or "Girth" of a box.
2) Formulas are: Volume = LWD (Length X Width X Depth)
Surface Area = 2LW + 2WD + 2LD
Girth = 2(L+W) + D
3) Input of the program will be a letter. "V" for volume. "A" for surface area. "G" for girth, and "Q" to stop the loop. (Q is the sentinel). The second part of the input will be a three (float) numbers representing the Length, Width, and Depth respectively.
For example: A 2.0 3.0 4.0 means find the surface area of a box with
Lenght= 2.0, Width= 3.0, and Depth= 4.0
4)For each input, just calculate what is called for, not all three answers. I have to use Nested if-else to control the actions.
5) Use Sentinel controlled while loops to read the data.
6) Libraries: iostream, iomanip (which i already put there)

And the inputs are: A 1.0 2.0 3.0
G 5.0 4.0 3.0
V 2.3 4.9 6.7
A 3.7 4.3 9.6
Q

Everytime I compile & run it, it would let me input "A 1.0 2.0 3.0" but nothing after that.
If anyone can help me, that would be really appreciated. Thank you!
Where are your brackets for your while loop?
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
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    float A, G, V, Q;
    const float SENTINEL = Q; //type to stop the loop
    float length, width, depth;
    char number;
    
    cout << "Enter numbers for Surface Area(A), Girth(G), and Volume(V). To stop the loop, enter Q." << endl;
     cin >> number;
     while(number != SENTINEL)
     {
     if (number == A)
        A = 2*length*width + 2*width*depth + 2*length*width;
     else if (number == G)
        G = 2*(length*width) + depth;
     else if (number == V)
        V = length * width * depth;
           
    
     cin >> number;
     }
    
    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         << setprecision(2)
         << "The surface area is " << A << endl;

    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         << setprecision(2)
         << "The girth+depth is " << G << endl;
         
    cout << setiosflags(ios::showpoint)
         << setiosflags(ios::fixed)
         <<setprecision(2)
         << "The volume is " << V << endl;



system("pause");
return 0;

}


Okay, i put the brackets around the while loop. Not sure if I put it right. But when i compile and run it... it works but the only problem is that it wont do the whole "calculations" that im looking for to find the surface area, volume, and girth.
Is there any way that part can be fixed?
What do you mean by "it wont do the whole "calculations""?
When i input:
A 1.0 2.0 3.0
G 5.0 4.0 3.0
V 2.3 4.9 6.7
A 3.7 4.3 9.6
Q

when i compile it... i want it to calcute the numbers to find the surface are of the 1st one (A 1.0 2.0 3.0), the girth in the 2nd (G 5.0 4.0 3.0), volume (V 2.3 4.9 6.7), and surface area again (A 3.7 4.3 9.6) and end the loop by entering Q.

But it would just keep going. Without doing what i hope it would do.
Are my formulas correct?
A = 2*length*width + 2*width*depth + 2*length*width
G = 2*(length*width) + depth
V = length * width * depth
Topic archived. No new replies allowed.