Question
Lab6 Circle class: //main #include #include #include Circle.h using namespace std; int main() { double radius; //Reading radius value cout > radius; //Creating a circle
Lab6 Circle class:
//main
#include
using namespace std;
int main() { double radius;
//Reading radius value cout > radius;
//Creating a circle class object Circle userCircle(radius);
//Set decimal to two decimal places cout
//Displaying details cout
return 0; }
//header
#ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED
//Class definition class Circle { private: double radius; const double pi; public: Circle(); Circle(double); void setRadius(double); double getRadius(); double getArea(); double getDiameter(); double getCircumference(); };
#endif // CIRCLE_H_INCLUDED
//cpp
#include "Circle.h"
/* Circle class implementation */
//Default constructor Circle::Circle():pi(3.14159) { radius = 0; }
//Parameterized Constructor Circle::Circle(double val):pi(3.14159) { radius = val; }
//setter method void Circle::setRadius(double val) { radius = val; }
//Getter method double Circle::getRadius() { return radius; }
//Getter method for area double Circle::getArea() { return (pi*radius*radius); }
//Getter method for diameter double Circle::getDiameter() { return (2*radius); }
//Getter method for Circumference double Circle::getCircumference() { return (2*pi*radius); }
CSE 112-Lab #13 Object Oriented Exception Handling with Classes Pages 1003, 1004, and 1005 - Rectangle (Version 3) and Program 16-5 Modify the Circle Class from Lab #6 to add exception handling for negative radius inputs. Modify the main program to use a try/catch as shown below (Ref: page 1005). This will require creating a NegativeRadius class in the Circle class as shown on page 1002/3. This will also require creating an instance of the circle before trying to set the radius in main. Submit a text file with the modified main, and header file. int main() double radius 0; //To hold a radius Circle userCircle; // create an instance of the circle cout >radius; try userCircle.setRadius(radius); // Display the circle's data. cout >radius; try userCircle.setRadius(radius); // Display the circle's data. coutStep 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