Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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" contructimage text in transcribed

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

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions