Construct a class named Circle that has a floating-point data member named radius. The class should have a zero-argument constructor that initializes this data member to 0. It should have member functions named calcCircumference) and calcArea() that calculate the circumference and area of a circle respectively, a member function setRadius()to set the radius of the circle, a member function getRadius() to return the radius, and a member function showData() that displays the circle's radius, circumference, and area. The formula for the area of a circle is A=rr?. The formula for the circumference of a circle is C=2ar. Use your class in a program that creates an instance of a Circle (utilizing the zero-argument constructor), prompts a user for a radius, calls the setRadius() function to set the circle's radius, and then calls showData() to display the circle's radius, circumference, and area. Your program should allow the user to enter circle dimensions until the user enters -1. Be sure to include appropriate error checking. Does i make sense to enter "abc" as the radius of a circle? No. Therefore, you should ensure that the user enters numeric data for the radius. Negative numbers (other than the -1 to exit) should also be prevented. showData() should not refer to the data members directly. Instead, it should call getRadius) to retrieve its value. Think of your getters and setters as middlemen. You should try to avoid accessing your data members directly due to maintenance issues. Pretend that you decided to change the name of your radius variable to be "rad". You really should only have to make that change in two functions: getRadius and setRadius. If you refer to the private data members directly throughout your code, you'll have a nightmare trying to make all the changes necessary. If you always use the getters to retrieve your data, any changes you make to the variable name will only necessitate changes to your get function rather than your whole code base. CalcCircumference. CalcArea, and ShowData should not have the radius passed in as an argument because radius is a data member of the class. Class functions have direct access to all data members in their own class. By passing in an argument for the value o the radius, you're not using the value that has already been stored in the data member. You're using the value that you've passed in to the functions, which circumvents the whole purpose of storing radius in the class. Be sure to avoid using global variables in your program unless they are constants. (Hint: a good constant to create in your program would be the value of pi.) • Finally, be sure not to include any unnecessary libraries.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Can you please help me write this in C++. I am so confused with all the added we have to implement. Thank you

Construct a class named Circle that has a floating-point data member named radius. The class
should have a zero-argument constructor that initializes this data member to 0. It should have
member functions named calcCircumterencel) and calcArea() that calculate the circumference
and area of a circle respectively, a member function setRadius(to set the radius of the circle, a
member function getRadius() to return the radius, and a member function showData() that
displays the circle's radius, circumference, and area. The formula for the area of a circle is
A-ar?. The formula for the circumference of a circle is C=2ar. Use your class in a program that
creates an instance of a Circle (utilizing the zero-argument constructor), prompts a user for a
radius, calls the şetRadius() function to set the circle's radius, and then calls showData() to
display the circle's radius, circumference, and area. Your program should allow the user to enter
circle dimensions until the user enters -1. Be sure to include appropriate error checking. Does it
make sense to enter "abc" as the radius of a circle? No. Therefore, you should ensure that the
user enters numeric data for the radius. Negative numbers (other than the -1 to exit) should also
be prevented.
showData() should not refer to the data members directly. Instead, it should call
getRadius() to retrieve its value. Think of your getters and setters as middlemen. You
should try to avoid accessing your data members directly due to maintenance issues.
Pretend that you decided to change the name of your radius variable to be "rad". You
really should only have to make that change in two functions: getRadius and setRadius.
If you refer to the private data members directly throughout your code, you'll have a
nightmare trying to make all the changes necessary. If you always use the getters to
retrieve your data, any changes you make to the variable name will only necessitate
changes to your get function rather than your whole code base.
CalcCircumference. CalcArea, and ShowData should not have the radius passed in as an
argument because radius is a data member of the class. Class functions have direct
access to all data members in their own class. By passing in an argument for the value of
the radius, you're not using the value that has already been stored in the data member.
You're using the value that you've passed in to the functions, which circumvents the
whole purpose of storing radius in the class. Be sure to avoid using global variables in
your program unless they are constants. (Hint: a good constant to create in your program
would be the value of pi.)
• Finally, be sure not to include any unnecessary libraries.
Transcribed Image Text:Construct a class named Circle that has a floating-point data member named radius. The class should have a zero-argument constructor that initializes this data member to 0. It should have member functions named calcCircumterencel) and calcArea() that calculate the circumference and area of a circle respectively, a member function setRadius(to set the radius of the circle, a member function getRadius() to return the radius, and a member function showData() that displays the circle's radius, circumference, and area. The formula for the area of a circle is A-ar?. The formula for the circumference of a circle is C=2ar. Use your class in a program that creates an instance of a Circle (utilizing the zero-argument constructor), prompts a user for a radius, calls the şetRadius() function to set the circle's radius, and then calls showData() to display the circle's radius, circumference, and area. Your program should allow the user to enter circle dimensions until the user enters -1. Be sure to include appropriate error checking. Does it make sense to enter "abc" as the radius of a circle? No. Therefore, you should ensure that the user enters numeric data for the radius. Negative numbers (other than the -1 to exit) should also be prevented. showData() should not refer to the data members directly. Instead, it should call getRadius() to retrieve its value. Think of your getters and setters as middlemen. You should try to avoid accessing your data members directly due to maintenance issues. Pretend that you decided to change the name of your radius variable to be "rad". You really should only have to make that change in two functions: getRadius and setRadius. If you refer to the private data members directly throughout your code, you'll have a nightmare trying to make all the changes necessary. If you always use the getters to retrieve your data, any changes you make to the variable name will only necessitate changes to your get function rather than your whole code base. CalcCircumference. CalcArea, and ShowData should not have the radius passed in as an argument because radius is a data member of the class. Class functions have direct access to all data members in their own class. By passing in an argument for the value of the radius, you're not using the value that has already been stored in the data member. You're using the value that you've passed in to the functions, which circumvents the whole purpose of storing radius in the class. Be sure to avoid using global variables in your program unless they are constants. (Hint: a good constant to create in your program would be the value of pi.) • Finally, be sure not to include any unnecessary libraries.
AutoSave O Off
Document1
Word
P Search (Alt+Q)
Steven Brightwel
SB
File
Home
Insert
Draw
Design
Layout
References
Mailings
Review
View
Help
PDFelement
A Share
P Comments
Compiles and Executes without crashing
No global variables
Appropriate Internal Documentation
Rectangle Class Created:
Çircle.h (header file)
Circle.cpp (class file)
CircleDriver.cpp (Driver file)
Data members:
Appropriate data members are declared
Style:
Appropriate Pre-processing and using directives
Constructor:
Zero argument constructor initializes data member to zero
Member functions are correct and used correctly:
calcCircumference()
calcArea()
setRadius()
getRadius()
showData()
Protection:
Member functions and variables are declared with appropriate
protection (i.e. private or public)
Object Creation:
Page 2 of 3
D Focus
540 words
English (United States)
100%
Transcribed Image Text:AutoSave O Off Document1 Word P Search (Alt+Q) Steven Brightwel SB File Home Insert Draw Design Layout References Mailings Review View Help PDFelement A Share P Comments Compiles and Executes without crashing No global variables Appropriate Internal Documentation Rectangle Class Created: Çircle.h (header file) Circle.cpp (class file) CircleDriver.cpp (Driver file) Data members: Appropriate data members are declared Style: Appropriate Pre-processing and using directives Constructor: Zero argument constructor initializes data member to zero Member functions are correct and used correctly: calcCircumference() calcArea() setRadius() getRadius() showData() Protection: Member functions and variables are declared with appropriate protection (i.e. private or public) Object Creation: Page 2 of 3 D Focus 540 words English (United States) 100%
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education