Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your task: implement in C++ the algorithm solution shown below Part A (79 points) Algorithn solution (in pseudocode): To accomplish this task, your program will

image text in transcribed
Your task: implement in C++ the algorithm solution shown below Part A (79 points) Algorithn solution (in pseudocode): To accomplish this task, your program will have to take the following steps: 1. Declare a variable named outFile that represents an output stream. 2. Declare a named constant PI that holds value 3.141592 3. Declare variables named side, radius, s cube, and s sphere that hold real numbers. 4. Open the file output.txt. 5. Prompt the user to "Enter side of cube: " 6. Read from keyboard the value entered by the user and assign it to side. 7. Prompt the user to "Enter radius of sphere 8 Read from keyboard the value entered by the user and assign it to radius. 9. Calculate the surface of the cube using the formula 6 s2 (where s is the side of the cube) and assign the result to s cube. culate the surface of the sphere using the fonula 4r2(where ris the radius of the and assign the result to s sphere. sphere 11. Format the output to display the numbers in fixed format with two decimal digits 12. Print to output.txt the message The surface of a cube of sides "side, "is"s cube. "The surface of a sphere of radius "radius, " s-sphere. 13. Close the file. To calculate the squares of a number you must define a value-returning function named square ) that receives a real number and returns its square as a real number. Then use it to calculate the squares of side and radius. Do NOT use pow0 in your program Part B (10 points) Modify the above program so that function square) rounds off the value to the nearest one hundredths (second decimal digit) before retuning it. CSCI 1380 Fall 2017 Rodger Irish Part C (11 points) Modify the abore program so that, instead of calculating the sufaces in main() you use a couple of value retuning functions named cube surf() and sphere surf) to do it. The fomer must receive the side of the cube while the latter must receire the radius of the sphere

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago