Question

Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace...

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 radius = " << radius << ", area = " << area

<< ", circumference = " << circumference << endl;

}

};

#endif // CIRCLE_H_INCLUDED

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#ifndef CIRCLE_H_INCLUDED
#define CIRCLE_H_INCLUDED
#include <iostream>
using namespace std;
class Circle        // Circle class
    {
private:
    double radius;      // private variable radius to hold radius of the circle
    // declaration of public methods in header file
public:
    Circle()            // default constructor which initializes radius to 1
    {
        // default value
        radius = 1;
    }
    void input()        // input method which reads a value into radius variable
    {
        cout << "Enter radius: ";
        cin >> radius;
    }
    void print()        // print method to print radius, area and circumference of the circle
    {
        double PI = 3.14159;
        double area = PI * radius * radius;         // calculate area of circle
        double circumference = 2 * PI * radius;     // calculate circumference circle
        cout << "Circle with radius = " << radius << ", area = " << area    // print circle details
             << ", circumference = " << circumference << endl;
    }
};
#endif // CIRCLE_H_INCLUDED
Add a comment
Know the answer?
Add Answer to:
Please add //comments to the header file below. #ifndef CIRCLE_H_INCLUDED #define CIRCLE_H_INCLUDED #include <iostream> using namespace...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • #include <iostream> using namespace std; class Circle{ // private member variable named radius private: double radius;...

    #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;...

  • Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string;...

    Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...

  • Help finding my errors in C++ please Header file #ifndef _FISH_SHOWER_H #define _FISH_SHOWER_H #include <iostream> #include...

    Help finding my errors in C++ please Header file #ifndef _FISH_SHOWER_H #define _FISH_SHOWER_H #include <iostream> #include <string> using namespace std; //NOTE: Prototypes are correct, use as a guide void WriteHeader(); void FillVectors(vector<string> &type, vector<int> &minGals, vector<int> &maxGallons); void AskFishShowerTypes(vector<string> &type, int *pIndex); void CalcPondVol(int *pGal); bool ValidateFishShower(int index, int pondVol, vector<int> &minGals, vector<int> &maxGals, vector<int> &rec); void WriteInfo(string showerType, int gallons); void WriteInfo(string showerType, vector<string> &showerTypes, vector<int> &recommendations, int gallons); #endif Main file #include "FishShower.h" using namespace std; int main()...

  • #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: //...

    #ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: // default constructor procReqRec() {} // constructor procReqRec(const string& nm, int p); // access functions int getPriority(); string getName(); // update functions void setPriority(int p); void setName(const string& nm); // for maintenance of a minimum priority queue friend bool operator< (const procReqRec& left, const procReqRec& right); // output a process request record in the format // name: priority friend ostream& operator<< (ostream& ostr, const procReqRec&...

  • Keep getting this error message when trying to compile in main1.cpp. Need help figuring out how...

    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...

  • C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream>...

    C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) {     /*     dynamic memory management     */     double * dmptr;     double circumference;         /*     add the code below to:     - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer     - assign 3.14 to the variable in heap via the pointer....

  • In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double...

    In C++ ***//Cat.h//*** #ifndef __Cat_h__ #define __Cat_h__ #include <string> using namespace std; struct Cat { double length; double height; double tailLength; string eyeColour; string furClassification; //long, medium, short, none string furColours[5]; }; void initCat (Cat&, double, double, double, string, string, const string[]); void readCat (Cat&); void printCat (const Cat&); bool isCalico (const Cat&); bool isTaller (const Cat&, const Cat&); #endif ***//Cat.cpp//*** #include "Cat.h" #include <iostream> using namespace std; void initCat (Cat& cat, double l, double h, double tL, string eC,...

  • Pure Abstract Base Class Project. Define a class called BasicShape which will be a pure abstract class. The clas...

    Pure Abstract Base Class Project. Define a class called BasicShape which will be a pure abstract class. The class will have one protected data member that will be a double called area. It will provide a function called getArea which should return the value of the data member area. It will also provide a function called calcArea which must be a pure virtual function. Define a class called Circle. It should be a derived class of the BasicShape class. This...

  • How to turn this file into a main.cpp, a header which contains the function declaration, and...

    How to turn this file into a main.cpp, a header which contains the function declaration, and a implementation fiel containing the function definition ? #include<iostream> #include<string> #include<iomanip> using namespace std; #define NUM 1 #define MULT 4 void getPi(int iter); int main() {    int it;    cout << "Enter the number of iterations needed to find PI: ";    cin >> it;    while (it < 1) {        cout << "Error!!! Iteration input should be positive." << endl;...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT