Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

8. Circle Class Write a Circle class that has the following member variables: . radius: a double pi: a double initialized with the value 3.14159

image text in transcribedimage text in transcribed
8. Circle Class Write a Circle class that has the following member variables: . radius: a double pi: a double initialized with the value 3.14159 The class should have the following member functions: . Default Constructor. A default constructor that sets radius to 0.0. . Constructor. Accepts the radius of the circle as an argument. . setRadius. A mutator function for the radius variable. . getRadius. An accessor function for the radius variable. . getArea. Returns the area of the circle, which is calculated as area = pi * radius * radius . getDiameter. Returns the diameter of the circle, which is calculated as diameter = radius * 2 . getCircumference. Returns the circumference of the circle, which is calculated as circumference = 2 * pi * radius Write a program that demonstrates the Circle class by asking the user for the circle's radius, creating a Circle object, and then reporting the circle's area, diameter, and circumference. SAMPLE RUN #0: ./circle_Non-Interactive Interactive Session Hide Invisibles Highlight: None V Show Highlighted Only O Calling . default . constructor: . The . circle's . radius . in . the . default . Circle . Object . is: . 04 Calling . setRadius (20) . to . change . radius . of . default: " The . circle's . radius . in . the . default . Circle . Object . is . Now: . 204 Creating . Circle . circle2(10) : . The . circle2's . radius . in . the . circle2 . Object . is: . 104 The . circle2's . area . is . therefore: . 314. 1594 The . circle2's . diameter . is . therefore: . 204 The . circle2's . circumference . is . therefore: . 62. 83184CODELAB ANALYSIS: LOGICAL ERROR(S) Problems Detected: The contents of your standard output is incorrect. You displayed: Enter the radius of the circle: The circle's radius is: 4.64103e-3104 The circle's area .is: 04 The circle's diameter is: 9.28206e-3104 The circle's circumference.is: 2.91604e-3094 instead of: Calling default.constructor: .The circle's.radius.in the default.Circle .Object is: 0~] Calling setRadius(20).to change.radius of default: ] The circle's radius.in the default.Circle.Object is.Now: 204 Creating.Circle.circle2(10):4 The circle2's radius.in the.circle2 .Object.is: 104 The circle2's area is therefore: 314.1594 The circle2's diameter is therefore: 20

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

Students also viewed these Programming questions