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.
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
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
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
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.Recommended textbooks for you
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
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)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education