Answered step by step
Verified Expert Solution
Question
1 Approved Answer
write C++ code for problem Problem: Suppose your geometry professor asks you to create a program that calculates the surface areas of a cube and
write C++ code for problem
Problem: Suppose your geometry professor asks you to create a program that calculates the surface areas of a cube and a sphere. In order to find these two values, your program needs to get the side of the cube and the radius of the sphere first and then, using them, calculate the corresponding areas using the formulas shown below. Surface area of cube: 6 x 52 Surface area of sphere: 4 x ixr? The values corresponding to s (side of the cube), r (radius of the sphere), and the calculated areas must be double precision real numbers. Your task: implement in C++ the algorithm solution shown below. Algorithm solution (in pseudocode): To solve this problem your program must perform the following tasks: Declare a global constant variable named PI that holds value 3.141592 Declare variables named side, radius, s_cube, and s_sphere that hold double precision real numbers Prompt the user to "Enter side of cube : " Read from keyboard the value entered by the user and assign it to side Prompt the user to "Enter radius of sphere : Read from keyboard the value entered by the user and assign it to radius Call cube_surf to calculate the surface area of the cube and assign the result to s_cube Call sphere_surf) to calculate the surface area of the sphere and assign the result to s_sphere Clear the screen Format the output to display the numbers in fixed format with two decimal digits Display on the screen the message "The surface of a cube of sides", side, "is", s_cube "The surface of a sphere of radius", radius," is ", s_sphere You need to define four value-returning functions to implement this solution Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started