Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a circle class in a separate header file that has the following private member variables: 1 . Radius: a double 2 . Pi: a

Create a circle class in a separate header file that has the following private member variables:
1. Radius: a double
2. Pi: a double initialized to 3.14159
The class will have the following member functions:
1. Default Constructor that sets the radius to 0.0(even though the program does not use it)
2. A Constructor that accepts the radius of the circle as an argument (the program will use this)
3. setRadius a mutator function for the radius variable
4. getRadius an accessor function for the radius variable
5. getArea returns the area of the circle (area = pi * radius * radius)
6. getDiameter returns the diameter of the circle ( diameter = radius *2)
7. getCircumference returns the circumference of the circle (circ =2* pi * radius)
Requirements:
Using the main function on the next page, write a program that demonstrates the circle class by
prompting the user for the circles radius (with input validation), create a circle object using the
overloaded constructor, and then report the area, diameter, and circumference with the output
precision set to (2) two decimal places. Use a separate header file for the class. Add a UML Diagram for
the class as a comment below main (10%).
The program will:
Use a separate *.h file for the class and a *.cpp file for main.
Use 3.14159 as the value for pi
Include #ifndef and #endif directives as required
Have a UML diagram of the Class with access specifiers, parameters, and return types (ref Figure
13-22 pg 826) as a comment below main.
//**********************************
// CLASS NAME
//**********************************
// MEMBER VARIABLES
//
//**********************************
// MEMBER FUNCTIONS
//(with access specifiers, parameters,
// and return types)
//**********************************
Grading will be based on meeting all of the lab requirements, adherence to programming standards,
operation and accurate output, and programming style including white space and indentation.
CSE 112 Introduction to Computer Science II
Assignments submitted after the due date will incur a grade penalty of three (3) points per day after
the first day, and will not be accepted more than one (1) week late.
Sample Main:
// Chapter 13, Programming Challenge 8: Circle Class
int main()
{
double radius =0; // To hold a radius
// Get the radius.
while (radius <=0)
{
cout << "Enter the circle's radius: ";
cin >> radius;
if(radius <=0)
cout << "That is not a valid radius." << endl >
I need help with visual studio using C++

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Briefly describe Bacons four Idols. How do the Idols apply today?

Answered: 1 week ago

Question

11.1 Explain the strategic importance of total rewards.

Answered: 1 week ago

Question

11.3 Define pay equity and explain its importance today.

Answered: 1 week ago