Area & Volume

I need help writing a program to find the area and volume of a cube or cone for a given choice of input character .
closed account (z05DSL3A)
You will (probably) need to show some effort and tell us what you are having a problem with to get help.

ps: This should be in the Beginners section.
area and volume

Area and volume are mathematically the same. I suggest, you begin with something simple like the volume of a circle, next same for a sphere (a "3D circle"), before you try such complex shapes like a cube or cone.
First prompt the user with something like "Pick (a) for a cone or (b) for a cube"

If he chose cube then ask the user for the length of a side and calculate the total surface area and volume of the cube.

Similarly if he chose cone then ask him for the cone's height and radius, then find total surface area and volume of the cone.

MikeStgt wrote:
Area and volume are mathematically the same.

¿ What do you mean they're the same ?
They're two different quantities of different dimensions that can't be compared. He probably meant total surface area when he said area by the way.

MikeStgt wrote:
I suggest, you begin with something simple like the volume of a circle, next same for a sphere (a "3D circle"), before you try such complex shapes like a cube or cone.

What are you alluding to (by the way a circle is 2D it doesn't have volume)? Finding the volume would involve just plugging values into a formula I would have thought.
They're two different quantities of different dimensions that can't be compared

A sphere of radius r with its center at the coordinates' origin could be written as x2+y2+z2<=r2, in "contrast" a circle would be x2+y2<=r2 (for the border of the volume replace '<=' by '='). Now, please, tell me where you do see the big difference.

Finding the volume would involve just plugging values into a formula I would have thought.

Sometimes it's a good idea to have a look behind the horizon (beyond your nose). In case of circle and sphere you have only to care about one value plugging into a formula, in case of a cube (cuboid) there may be some more, what could repel beginners.
closed account (z05DSL3A)
MikeStgt, the more you post the more I wonder about your motives.
Sorry, @MikeStgt, but I agree with @Grime. The physical dimensions are different and they shouldn't be compared. Only for extremely simple shapes are the equations of their bounding surfaces similar. Any equation where physical dimensions are inconsistent should raise a red alarm immediately.

As for a cube: formulae for its volume and surface area are about as simple as it gets.

So, OP, write a code to input some dimensions and plug them in far-from-challenging formulae. That's it.
I wonder about your motives

LOL! -- What are yours to hang out at this list? :)

Any equation where physical dimensions are inconsistent should raise a red alarm immediately.

Sure, no doubt. Please consider, I did not combine the formulas of the sphere and circle, I did put them side by side to show the similitudes (what could enable you now to write down without effort the formula of a sphere of four dimensions). I only wantet do show, that "the volume of a circle" is not wrong in a mathematical sense.
RosieMicheals, I suggest that you do this in stages:
1. Write a program that prompts the user for a number and prints it out.
2. Change it to compute the surface area and volume of a square whose side is the number, and print the result.
3. Modify it to do the same for a cone. You haven't told us some of the details, such as whether you're supposed to ask the user if they want to compute for a cube or cone, or whether you're supposed to compute the values for both all the time. If you post the text of the assignment we can help with that too.

Important note: In C++ a^3 is not the way you write a3. In other words, ^ is not the power operator. It's something called "exclusive or." You have to use pow(a,3), or just a*a*a to cube a number. Do similar code to raise it to a different power.
MikeStgt wrote:
Sometimes it's a good idea to have a look behind the horizon (beyond your nose). In case of circle and sphere you have only to care about one value plugging into a formula, in case of a cube (cuboid) there may be some more, what could repel beginners.

Why would finding the volume of a cube NOT require plugging in just one value? How else will you find the volume?

Just to make sure we're on the same page:
Volume = (side of square) ^ 3
Total Surface Area = 6 x (side) ^ 2


Perhaps you thought that OP has to find the area/volume by using the coordinates of the cube/cone. A cube's 4 vertices as coordinates is definitely enough to find the area/volume of a cube. But what about a cone?

What you've said simply makes no sense to me. I'm sorry.
I'm sorry.

So am I.
Question (may be related to my poor English): is a cube at all events (as well ice cubes, soup cubes, stock cubes, and lump sugar) that special case of a cuboid where all edges are the same length and all adjacent edges are perpendicular?
Okay man. I just wanted to know HOW you would find the volume. So how would you find the volume?

Question (may be related to my poor English): is a cube at all events (as well ice cubes, soup cubes, stock cubes, and lump sugar) that special case of a cuboid where all edges are the same length and all adjacent edges are perpendicular?

Yep. A cube is a geometric shape which is a special case of a cuboid. Ice cubes, soup cubes, stock cubes and lump sugar have the shape of a cube.
closed account (z05DSL3A)
MikeStgt, you say 'may be related to my poor English', maybe elements lost in translation are what lead me to wonder about your motives, sorry.
MikeStgt, you say 'may be related to my poor English', maybe elements lost in translation are what lead me to wonder about your motives, sorry.

He's probably not using a translator guessing by an innocent typo.
("I only wantet do show" - wantet is not a word so a translator wouldn't have given that)

And his English is a thousand times better than any english translator out there.
maybe elements lost in translation are what lead me to wonder about your motives, sorry.
Grey Wolf

From my point of view, you do not have any reason to feel sorry. Your question about my motives is perfect, as it was a nice hint to reflect what I am doing. My first idea was -- have some fun, second thought -- as all here. Most fun is, to get a hint, another is, to help, to give a tip. My hint here was obviously too hard to grasp. The OP asked:
I need help writing a program to find the area and volume of a cube or cone...
and my answer was basically: get the fundamentals.

Yep. A cube is a geometric shape which is a special case of a cuboid. Ice cubes, soup cubes, stock cubes and lump sugar have the shape of a cube.
Grime

Here in Germany, they sell lump sugar with non-equal edge length, see https://www.yopi.de/product_images/281/281669/lightbox/ja-wuerfelzucker.png
Same with soup cubes -- https://media1.faz.net/ppmedia/aktuell/finanzen/3831491177/1.2819897/default/bruehwuerfel-die-keimzelle-des.jpg
So we call it cube even it's a cuboid.
closed account (367kGNh0)
Please in future put these posts in the beginners section. such a task is incredibly easy, you don't even need our help if you spend time each day LEARNING C++. Once you know the equation for the area of these shapes, put them in equations, give them variables and BAM!
Topic archived. No new replies allowed.