Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab6 Circle class: //main #include #include #include Circle.h using namespace std; int main() { double radius; //Reading radius value cout > radius; //Creating a circle

image text in transcribed

Lab6 Circle class:

//main

#include #include #include "Circle.h"

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. cout

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago