Question: In C++ modify this Circle Struct into a Circle Class, additionally add a try/catch contruct Copied code: #include #include #include // For the pow function

In C++ modify this Circle Struct into a Circle Class, additionally add a "try/catch" contructIn C++ modify this Circle Struct into a Circle Class, additionally add

Copied code:

#include #include #include // For the pow function using namespace std; using namespace std;

// Constant for pi. const double PI = 3.14159;

// Structure declaration struct Circle { double radius; double diameter; double area; }; // Function prototype Circle getInfo();

int main() { Circle c; // Get data about the circle. c = getInfo(); // Calulate the circle's area. c.area = PI * pow(c.radius, 2.0); //Display the circle data. cout

//*************************************************************** // Definition of function getInfo. This function uses a local * // variable, tempCircle, which is a circle structure. The user * // enters the diameter of the circle, which is stored in * // tempCircle.diameter. The function then calculates the radius * // which is stored in tempCircle.radius. tempCircle is then * // returned from the function. * //***************************************************************

Circle getInfo() { Circle tempCircle; // Temporary structure variable // Store circle data in the temporary variable. cout > tempCircle.diameter; tempCircle.radius = tempCircle.diameter / 2.0; // Return the temporary variable. return tempCircle; }

#include 8 #include 9 #include // For the pow function using name space std; 10 using namespace std; 2// Constant for pi 13 const double PI -3.14159; 14 15 Structure declaration 16 struct Circle 17 double radius; double diameter; double area 19 23 // Function prototype 24 Circle getInfo); 25 26 int main Circle c // Get data about the circle c getInfo); 31 32 /I Calulate the circle's area c .area = P! * pow (c.radius, 2.0); 35 //Display the circle data cout > tempCircle.diameter; tempCircle. radius tempCircle . diameter / 2.0; // Return the temporary variable return tempCircle

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!