Need help cant figure it out its in C++

Welcome to the Get Help category!

This is where you can ask questions about your code. Some important things to remember when posting in this category :slight_smile:

  • Learn how to ask a good question and get a good answer!
  • Remember to include a link to the exercise you need help with!
  • If someone answers your question, please mark their response as a solution :white_check_mark:
  • Once you understand a new concept, come back and try to help someone else!
#include <iostream> #include <cmath> using namespace std; #include <string> const int Cube = 1; const int Sphere = 2; const int Prism = 3; const int Cylinder = 4; const int Cone = 5; const int Quit = 6; double readDouble(string promt); //double base; //double side; //double radius; //double height; //double width; int main() { int Menuchoice = 0; while (Menuchoice =! Quit){ cout << "1. (C)ube\n2. (S)phere\n3. (P)rism\n4. (Cy)linder\n5. (Co)ne\n6"; cin >> Menuchoice; switch (Menuchoice) { case Cube: { double side = 0.0; cout<< readDouble("Enter the side in inches"); cin >> side; double surArea= 6 * pow(side,2.0); double volume = pow(side,3.0); cout << "Surface area is "<< surArea << "cubic inches\n"; cout << "Volume is " << volume << "cubic inches\n "; } break; case Sphere: { double radius = 0.0; cout << readDouble("Enter the radius in inches"); cin>> radius; double surArea = 4 * M_PI * pow(radius,2.0); double volume = 4.0 / 3.0 * M_PI * pow(radius,3.0); cout <<"Surface area is " << surArea << "cubic inches\n"; cout << "Volume is " << volume << " cubic inches\n"; } break; case Prism: { double base = 0.0, height = 0.0 ,length = 0.0, width = 0.0, p = 0.0, b = 0.0; cout<< readDouble("enter the length in inches"); cin>> length; cout << readDouble("Enter the width in inches"); cin >> width; cout << readDouble("enter the height in inches"); cin >> height; //Base b = length * width; //Perimeter p = 2 * length * width; double surArea = (2 * b) + (p * height); double volume = b * height ; cout << "Surface area is " << surArea << "cubic inches\n"; cout << "volume is " << volume << "cubic incehs\n"; } break; case Cylinder: { double height = 0.0 , radius = 0.0; cout << readDouble("Enter the height in inches"); cin >> height; cout << readDouble("Enter the radius in inches"); cout << radius; double surArea = (2 * M_PI * radius * height) + 2 * M_PI * pow(radius, 2.0); double volume = M_PI * pow(radius, 2.0) * height; cout << "Surface area is " << surArea << "cubic inches\n"; cout << "volume is " << volume << "cubic incehs\n"; } break; case Cone: { double radius = 0.0, length = 0.0, height = 0.0; cout << readDouble("enter the radius in inches"); cin >> radius; cout << readDouble("enter the lenth in inches"); cin >> length; double surArea = (M_PI * pow(radius,2.0)) + (radius * M_PI * length); double volume = M_PI * pow(radius,2.0) * (height / 3 ); cout << "Surface area is " << surArea << "cubic inches\n"; cout << "volume is " << volume << "cubic incehs\n"; } break; case Quit: cout<< "Goodbye\n"; break; default: cout << "Error!!! invalid menu choice\n"; break; } } return 0; }

Please be more specific on what are you trying to figure out.
Is it a compilation error? Or does your code not function as it is expected?
Providing more details tend to increase the probability of your problem being resolved by others.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.