Problem:

Write a c++ program to calcualte the surface area, volume, or "girth + depth" of a box:

the formulas are as follows;

volume = LWD (lengthxwidthxdepth)

surface area= 2lw plus 2wd plus 2ld

girth + depth = 2(l+w) plus d

2. the input of the program will be a letter. V will indicate volume. A is surface area. G is girth plus depth, 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.

3. for each input, just calculate what is called for, not all three ansers. Use NESTED if-elses, or a switch structure to control your actions. THe output should have appropriate labels. Use format to control the appearance of your answers.

4. use sentinel controlled while loops to read the data. The Q for the operation will be the sentinel. THe program should work for any data set, not just the data set below.

5. libraries: iostream, iomanip

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

Output: as specified above

So that's the project and this is what I have so far

#include <iostream>

#include <iomanip>

using namespace std;

int main ()

{

int V, A, G, Q;

const int SENTINEL = Q; // Cease Loop

float length,width,depth;

V = length*width*depth;

A = 2*(length*width) + 2*(width*depth) + 2*(length*depth);

G = 2*(length*width) + depth;

system ("Pause");

return 0;

}

Write a c++ program to calcualte the surface area, volume, or "girth + depth" of a box:

the formulas are as follows;

volume = LWD (lengthxwidthxdepth)

surface area= 2lw plus 2wd plus 2ld

girth + depth = 2(l+w) plus d

2. the input of the program will be a letter. V will indicate volume. A is surface area. G is girth plus depth, 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.

3. for each input, just calculate what is called for, not all three ansers. Use NESTED if-elses, or a switch structure to control your actions. THe output should have appropriate labels. Use format to control the appearance of your answers.

4. use sentinel controlled while loops to read the data. The Q for the operation will be the sentinel. THe program should work for any data set, not just the data set below.

5. libraries: iostream, iomanip

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

Output: as specified above

So that's the project and this is what I have so far

#include <iostream>

#include <iomanip>

using namespace std;

int main ()

{

int V, A, G, Q;

const int SENTINEL = Q; // Cease Loop

float length,width,depth;

V = length*width*depth;

A = 2*(length*width) + 2*(width*depth) + 2*(length*depth);

G = 2*(length*width) + depth;

system ("Pause");

return 0;

}

Topic archived. No new replies allowed.