1.
Complete the following code:
Design a class called Circle. The class should have an integer member variable named radius and three member functions; setRadius, getRadius, calArea;
the functions' prototypes should be done inside the class declaration and the functions' definitions should come after the main function
#include <iostream>
using namespace std;
const double PI = 3.14;
// fill in the declaration
of the class Circle
here
int main() {
Circle c1;
int input;
cout << "please enter the radius for the circle:";
cin >> input;
c1.setRadius(input);
cout << "The radius of the circle is: " <<
c1.getRadius() << endl;
cout << "The area of the circle is: " << c1.calArea()
<< endl;
}
// fill in the
implementation of the member functions here
//sample run
/*please enter the radius for the circle: 6
The radius of the circle is: 6
The area of the circle is: 113.04
Press any key to continue . . .*/
#include <iostream>
using namespace std;
const double PI = 3.14;
// fill in the declaration of the class Circle here
class Circle{
public:
int radius;
int getRadius();
void setRadius(int i);
double calArea();
};
int main() {
Circle c1;
int input;
cout << "please enter the radius for the circle:";
cin >> input;
c1.setRadius(input);
cout << "The radius of the circle is: " <<
c1.getRadius() << endl;
cout << "The area of the circle is: " << c1.calArea()
<< endl;
}
//writing the definations for the classes
int Circle :: getRadius(){
return radius;
}
void Circle::setRadius(int i){
radius=i;
}
double Circle:: calArea(){
return 3.1415 * radius * radius;
}

Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me
Need C++ Code (Please put //comments on there too) 1. Complete the following code: Design a...
C++ programming question will upvote
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...
A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following: int main() { double radius; double area; double circumference; //the radius...
Keep getting this error message when trying to compile in main1.cpp. Need help figuring out how to make it compile. Thank you for your time. Error Message: main.cpp:(.text+0x13): undefined reference to `circle::circle()' main.cpp:(.text+0x32): undefined reference to `circle::circle(double)' main.cpp:(.text+0x3e): undefined reference to `circle::getArea() const' main.cpp:(.text+0x53): undefined reference to `circle::getRadius() const' main.cpp:(.text+0xb3): undefined reference to `circle::getArea() const' main.cpp:(.text+0xc8): undefined reference to `circle::getRadius() const' main.cpp:(.text+0x157): undefined reference to `circle::setRadius(double)' main.cpp:(.text+0x163): undefined reference to `circle::getArea() const' main.cpp:(.text+0x178): undefined reference to `circle::getRadius() const' main.cpp:(.text+0x207): undefined...
Need some help on this C++ program. Circle - color:String - radius:double +Circle() +Circle(newColor:String, newRadius:double) +setColor(color:String):void +setRadius(radius:double):void +getColor():String +getRadius():double +printCircleInfo():void Create the class using three files - a .h, a .cpp and a main.cpp Create a class called Circle as describe below Constructor with no arguments Sets radius to 1 and color to “black” Constructor with arguments Sets the color and radius to the values passed in Get methods (accessors) return the field that the get refers to Set methods...
modify sample code from example two to calculate the surface area
and volume of a sphere givin the radius
int main() Example 2 Introduction to structures and passing the structure variables as arguments into functions. 1. A structure is created with circle related variables. 2. Two functions are created related to circle calculations. 3. This example passes structure variables from the main function to the message Circle function 4. The message Circle function converts the structure variables into regular double...
#include <iostream> using namespace std; class Circle{ // private member variable named radius private: double radius; // get function for radius public: double getRadius(){ return radius; } // set function for radius void setRadius(double rad){ radius=rad; } // returning area = 3.14159 * radius * radius double getArea(){ return (3.14159 * radius * radius); } }; // Sample run int main() { // Declaring object of Circle Circle myCircle; myCircle.setRadius(5); // printing radius of circle cout<<"Radius of circle is: "<<(myCircle.getRadius())<<endl;...
PLEASE TYPE OUT IN TEXT (please no pdf or writing) C++ CODE Consider the following program in which the statements are in the incorrect order. Rearrange the statements in the following order so that the program prompts the user to input: The height of the base of a cylinder The radius of the base of a cylinder The program then outputs (in order): The volume of the cylinder. The surface area of the cylinder Format the output to two decimal...
Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace std; class Circle { private: double radius; // declaration of public methods in header file public: Circle() { // default value radius = 1; } void input() { cout << "Enter radius: "; cin >> radius; } void print() { double PI = 3.14159; double area = PI * radius * radius; double circumference = 2 * PI * radius; cout << "Circle with...
c++ Please help! i keep getting an error message. I think my
main problem is not understanding the circle calculations function
and how both the area and the circumference is returned from the
function. I know & needs to be used, but I am unsure how to use
it.
Copy the following code and run it. You should break it into the following 3 functions getValidinput - which asks the user to enter the radius and then make sure that...
Note- can you rewrite the code in C++ if there is any existing code. Can you not use arrow -> operator. 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...