Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im having trouble figuring out the call function part. If possible please follow the format also #include // to use cin and cout #include //

Im having trouble figuring out the call function part. If possible please follow the format also

#include // to use cin and cout

#include // to be able to use operator typeid

#include

#include

#include

// Include here the libraries that your program needs to compile

using namespace std;

// Ignore this; it's a little function used for making tests

inline void _test(const char* expression, const char* file, int line)

{

cerr << "test(" << expression << ") failed in file " << file;

cerr << ", line " << line << "." << endl << endl;

}

// This goes along with the above function...don't worry about it

#define test(EXPRESSION) ((EXPRESSION) ? (void)0 : _test(#EXPRESSION, __FILE__, __LINE__))

// Insert here the prototypes of the functions

double cube_surf(double side);

double sphere_surf(double radius);

// Declare a global constant variable named PI that holds value 3.141592

const double PI = 3.141592;

int main()

{

// Declare variables named side, radius, s_cube, and s_sphere that hold double precision real numbers

double side, radius, s_cube, s_sphere;

// Prompt the user to "Enter side of cube : "

cout << "Enter side of cube : " << endl;

// Read from keyboard the value entered by the user and assign it to side

cin >> side;

// Prompt the user to "Enter radius of sphere : "

cout << "Enter radius of sphere : " << endl;

// Read from keyboard the value entered by the user and assign it to radius

cin >> radius;

// Call cube_surf() to calculate the surface of the cube and assign the result to s_cube

s_cube = 6 * (pow(side, 2));

// Call sphere_surf() to calculate the surface of the sphere and assign the result to s_sphere

s_sphere = 4 * PI * (pow(radius, 2));

// 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 area of a cube of sides ", side, " is ", s_cube

// "The surface area of a sphere of radius ", radius, " is ", s_sphere

//system("pause");

cout << " The surface area of a cube of sides " << fixed<

cout << "The surface area of a sphere of radius " <

// Do NOT remove or modify the following statements

cout << endl << "Testing your solution" << endl << endl;

test(typeid(side) == typeid(1.)); // Incorrect data type used for side

test(typeid(radius) == typeid(1.)); // Incorrect data type used for radius

test(typeid(s_cube) == typeid(1.)); // Incorrect data type used for s_cube

test(typeid(s_sphere) == typeid(1.)); // Incorrect data type used for s_sphere

test(fabs(cube_surf(3.36) - 67.74) < 0.001); // Incorrect rounding of value returned by cube_surf()

test(fabs(cube_surf(3.37) - 68.14) < 0.001); // Incorrect rounding of value returned by cube_surf()

test(fabs(sphere_surf(4.23) - 224.85) < 0.001); // Incorrect rounding of value returned by sphere_surf()

test(fabs(sphere_surf(4.29) - 231.27) < 0.001); // Incorrect rounding of value returned by sphere_surf()

//system("pause");

return 0;

}

//************************ Function definition *************************

// Read the handout carefully for detailed description of the functions that you have to implement

// Calculate the square of the value received

// Calculate the surface area of the cube using the formula 6 x side^2 (six times the square of the side of the cube)

// Calculate the surface area of the sphere using the formula 4 x Pi x radius^2 (four times Pi times the square of the radius of the sphere)

// Rounds the value received in the first parameter to the number of digits received in the second parameter

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago