i am supposed to make a menu similar to the code below that when you enter options 1-6 and for each option theres a shape and you have to enter in the dimensions of the shape and it will give back the surface area and the volume.
the code blow is how i want to start it but I'm not sure how to add the functions to do what i said i want. i was absent from the class that went over how to do this. so if anyone could help me that'll be great.
Start with asking the user to input the dimensions of the shape they chose.
I'm not sure what you want to happen after that - are you supposed to compute other properties of the shape? I can't imagine you'd be drawing 3D figures in the console.
No I'm not drawing any shapes. What I want to happen is they input the dimensions of the shape and then it will output the volume and the surface area of the shape. That's what I'm having trouble with. I don't know where to put that code.
If you would want to add functions into your current code, it would be a pain in the a**.
Because these shapes have different formulas, (the SA of a cube is different than the SA of a cyninder), you would need a seperate function for each shape with arguments for all the information uniquely necessary for that shape. It would honestly be more efficient to just add all the information in the cases.
I'm going to tell you what is needed to accomplish it, I'm sure you can figure it out from here.
-You need to ask for and get input for all the properties of each shape. (I.e. If case cube, ask for length of side)
-You need to calculate the volume and SA's of each shape. (That's just formulas, you can look them up)
-And finally, you have to output the answers to these using cout << (variable name or equation)
All of these things could go in a case, unless your teacher specifically said to use functions, in which case you can make a custom function propsOfCylinder(double r, double h) {} for each shape and go from there. Good luck :D Feel free to reply with questions
so i went through, put all the formulas into the cases, and now for cases 2-6 and the default case i get the message "Switch Case is in protected scope." how would i go about fixing that?