Lab 5.cpp - Author Brianna Scott Lab 5 Classes/preprocessor...

This preview shows page 1 - 2 out of 2 pages.

/* Author: Brianna Scott 9/29/16 Lab 5 - Classes */ //preprocessor directives #include <iostream> #include <iomanip> //namespace statement using namespace std; //circleType Class class circleType { public: //public function prototypes void setRadius(double r); double getRadius(); double area(); double circumference(); //constructor circleType(double r = 0); private: //private function prototypes double radius; }; //Outside Class Implementations void circleType::setRadius(double r) { if (r >= 0) radius = r; else radius = 0; } double circleType::getRadius() { return radius; } double circleType::area() { return 3.14 * radius * radius; //pi * r * r } double circleType::circumference() { return 2 * 3.14 * radius; // 2 * pi * r } circleType::circleType(double r) { setRadius(r); } //main function int main () { //Enter two variables below
Image of page 1

Subscribe to view the full document.

double radius1; double radius2; //two class objects circleType circle1; circleType circle2; //Introduction to the Program cout << "Hello." << endl; cout << "Welcome to the C++ program on classes. The objective is " << endl; cout << "to find out the area and circumference of two circles & " << endl; cout << "return which is largest, the smallest, or if they are equal." << endl; cout << "You may begin now." << endl; //Prompt user to enter radius for circle 1 cout << "Enter the radius for circle 1: "; cin >> radius1;
Image of page 2

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern