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

Write a c++ program to calculate the surface area, volume, or \"girth + depth\"

ID: 3631448 • Letter: W

Question

Write a c++ program to calculate the surface area, volume, or "girth + depth" of a box. The formulas are as follows: volume= length*width*depth. surface area =2lw+2wd+2ld. Girth+depth= 2(l+w) +d . (girth+depth is used in shipping). The input of the program will be a letter. "v" will indicate volume, "a" the surface area, "g" the firth plus dpeth, 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 each input, just calculate what is called for, not all three answers. 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. Use sentinel 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. 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

Explanation / Answer

#include #include #define PI 3.14159265359 using namespace std; float psquare (float a) { return (4*a); } float prectangle (float w, float l) { return ((2*w)+(2*l)); } float pparallelogram (float b, float h) { return ((2*b)+(2*h)); } float ptrapezoid (float s, float t, float b) { return ((2*s)+b+t); } float pcircle (float r) { return (PI*r*2); } float pellipse (float r, float s) { return (PI*(r+s)); } float ptriangle (float a, float b, float c) { return (a+b+c); } float asquare (float a) { return (a*a); } float arectangle (float l, float w) { return (l*w); } float aparallelogram (float b, float h) { return (h*b); } float atrapezoid (float t, float b, float h) { return (h/2*(t+b)); } float acircle (float r) { return (PI*r*r); } float aellipse (float r, float s) { return (PI*r*s); } float atriangle (float b, float h) { return (b*h/2); } float scube (float a) { return (a*a*6); } float vcube (float a) { return (a*a*a); } float scylinder (float r, float h) { return ((2*PI*r*h)+(2*PI*(r*r))); } float vcylinder (float r, float h) { return (PI*(r*r)*h); } float scone (float r, float s) { return ((s*PI*r)+(PI*(r*r))); } float vcone (float r, float h) { return (1/3*PI*(r*r)*h); } float ssphere (float r) { return (4*PI*(r*r)); } float vsphere (float r) { return (4/3*PI*(r*r*r)); } float sprism (float B, float P, float h) { return ((2*B)+(P*h)); } float vprism (float B, float h) { return (B*h); } float spyramid (float B, float s, float l, float n) { return (B+n*(1/2*s*l)); } float vpyramid (float B, float h) { return (1/3*B*h); } float ppentagon (float a) { return (5*a); } float phexagon (float a) { return (6*a); } float apentagon (float a, float s) { return (a*s*5/2); } float ahexagon (float a, float s) { return (a*s*6/2); } int main () { dimension: string d, s, t, p; float x, y, z, h, perimeter, area, average; char n; cout d; if ( (d == "2d") || (d == "2D") || (d == "2") ) { type: cout t; if ( (t == "perimeter") || (t == "Perimeter") || (t == "p") || (t == "P") ) {t="perimeter";} else if ( (t == "Area") || (t == "area") || (t == "a") || (t == "A") ) {t="area";} if ( (t == "perimeter") || (t == "area") ) { shape: cout s; if ( (s == "Square") || (s == "square") || (s == "s") || (s == "S") ) {s="square";} else if ( (s == "Rectangle") || (s == "rectangle") || (s == "R") || (s == "r") ) {s="rectangle";} else if ( (s == "parallelogram") || (s == "Parallelogram") || (s == "p") || (s == "P") ) {s="parallelogram";} else if ( (s == "trapezoid") || (s == "Trapezoid") || (s == "trap") || (s == "Trap") ) {s="trapezoid";} else if ( (s == "Circle") || (s == "circle") || (s == "C") || (s == "c") ) {s="circle";} else if ( (s == "Ellipse") || (s == "ellipse") || (s == "E") || (s == "e") ) {s="ellipse";} else if ( (s == "triangle") || (s == "Triangle") || (s == "t") || (s == "T") ) {s="triangle";} if ( (s == "square") || (s == "rectangle") || (s == "parallelogram") || (s == "trapezoid") || (s == "circle") || (s == "ellipse") || (s == "triangle") ) { if (s == "square") { goto square; } else if (s == "rectangle") { goto rectangle; } else if (s == "parallelogram") { goto parallelogram; } else if (s == "trapezoid") { goto trapezoid; } else if (s == "circle") { goto circle; } else if (s == "ellipse") { goto ellipse; } else if (s == "triangle") { goto triangle; } square: if (t == "perimeter") { cout x; cout
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