## calculating volumes of geometric solids

## calculating volumes of geometric solids

(OP)

The assignment requires to promt the user for a x and y value, and then have it output the volume of a cylinder (x as base; y as height); volume of a cone (x as base; y as height); and the volume of a sphere (use average of x and y as radius).

I have made numerous attempts to figure this out, but I keep ending up with errors and was wondering where I was going wrong. I really appreciate any guidance/help I can get.

/*

input: value of x and y

output: volume of cylinder; volume of cone; volume of sphere

*/

#include <iostream>

#include <iomanip>

#define _USE_MATH_DEFINES

#include <cmath>

#include <string>

using namespace std;

int main(void) {

double x;

double y;

double base;

double height;

double radius;

double volume_cylinder;

double volume_cone;

double volume_sphere;

double average;

cout << fixed << setprecision(11) << M_PI << endl;

//Input

cout << "Please enter a value for x ";

cin >> x;

cout << "Please enter a value for y ";

cin >> y;

// Calculations

base = x;

height = y;

base_squared = base * base;

volume_cylinder = (M_PI)*(base_squared)*(height);

volume_cone = (1.0/3.0)*(M_PI)*(base_squared)*(height);

average = ((base) + (height))/2.0

base_cubed = base * base * base

volume_sphere = (4.0/3.0)*(M_PI)*(base_cubed)

// Output

cout << fixed << setprecision(2);

cout << "The volume of the cylinder is " << volume_cylinder << endl;

cout << "The volume of the cone is " << volume_cone << endl;

cout << "The volume of the sphere is " << volume_sphere << endl;

return 0;

}

I have made numerous attempts to figure this out, but I keep ending up with errors and was wondering where I was going wrong. I really appreciate any guidance/help I can get.

/*

input: value of x and y

output: volume of cylinder; volume of cone; volume of sphere

*/

#include <iostream>

#include <iomanip>

#define _USE_MATH_DEFINES

#include <cmath>

#include <string>

using namespace std;

int main(void) {

double x;

double y;

double base;

double height;

double radius;

double volume_cylinder;

double volume_cone;

double volume_sphere;

double average;

cout << fixed << setprecision(11) << M_PI << endl;

//Input

cout << "Please enter a value for x ";

cin >> x;

cout << "Please enter a value for y ";

cin >> y;

// Calculations

base = x;

height = y;

base_squared = base * base;

volume_cylinder = (M_PI)*(base_squared)*(height);

volume_cone = (1.0/3.0)*(M_PI)*(base_squared)*(height);

average = ((base) + (height))/2.0

base_cubed = base * base * base

volume_sphere = (4.0/3.0)*(M_PI)*(base_cubed)

// Output

cout << fixed << setprecision(2);

cout << "The volume of the cylinder is " << volume_cylinder << endl;

cout << "The volume of the cone is " << volume_cone << endl;

cout << "The volume of the sphere is " << volume_sphere << endl;

return 0;

}

## RE: calculating volumes of geometric solids

Please, next time explain your problems explicitly.

It seems that

I keep ending up with errors and was wondering where I was going wrongis a very strange help request in that case.