Sponsored Links


Results 1 to 6 of 6

Thread: cs201 assignment no 3 idea solution spring June 2011

  1. #1
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578

    Icon14 cs201 assignment no 3 idea solution spring June 2011

    Sponsored Links1


    Assignment No. 3
    Semester: Spring 2011
    CS201: Introduction to Programming Total Marks: 20

    Due Date:13 June, 2011

    Instructions:
    Please read the following instructions carefully before submitting your assignment:
    It should be clear that your assignment will not get any credit if:

     The assignment is submitted after due date.
     The submitted assignment does not open or file is corrupt.

    All types of plagiarism are strictly prohibited.

    Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in any other file format like .doc or .txt etc. you will get zero marks.

    Objective
    The objective of this assignment is to provide hands on experience of using

     Macros in C/C++
     Classes in C/C++
     Creating Default constructors and User-defined constructors
     Creating and manipulating objects.

    Guidelines
     Code should be properly aligned and well commented.
     Follow C/C++ rules while writing variables names, function names etc.
     Use only Dev-C++ IDE for this assignment.
    Assignment

    Problem Statement: Circle Area & Circumference Calculation

    You are required to write a program which will calculate the area and circumference of the circle by declaring a class. You must declare a class named Circle whose only data member will be radius which should be declared as public. You need to define a macro for the value of PI which will be used while calculating the area of the circle.


    Detailed Description:

    • Data member radius should be of type double and it should be declared under public scope.

    • Value for PI should be defined using #define macro.

    • Your class should have two type of constructors:

    1. Default Constructor which should initialize radius of the circle with value 0.

    2. User Defined Constructor which takes class data member radius as its parameter.

    • Declare a public member function named CalculateArea() which calculates the area of the circle. The formula for calculating the area is .

    • Declare a public member function named CalculateCircum() which calculates the circumference of the circle. The formula for calculating the circumference is .

    • Declare a public member function named Display which will display the calculated area and circumference of the circle on the output screen.

    • In the main() function, declare two objects of type Circle:

    o One using default constructor
    o Second using user-defined constructor.

    It should be Display the area and circumference of the circle on the screen like the sample output.


    Sample Output:

    Sponsored Links

    Radius of the Circle = 0
    Area of the Circle = 0
    Circumference of the Circle is = 0


    Radius of the Circle = 3.5
    Area of the Circle = 38.465
    Circumference of the Circle is = 21.98



    Deadline:
    Your Assignment solution must be submitted on or before June 13, 2011. You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. Assignment submitted in any other file format like .doc or .txt etc. you will get zero marks.
    Attached Files Attached Files

  2. #2
    Junior Member shafiq856's Avatar
    Join Date
    Jul 2010
    Location
    Muzaffargarh
    Posts
    14

    18

    CS201 Assignment 3 Spring 2011

    #include <iostream>
    #include <cmath>
    #include <iomanip>

    using namespace std;

    int main()
    {
    float radius;
    float fAreaCircle;
    float fCircumferenceCircle;

    cout << "\nEnter the radius of circle: " ;
    cin >> radius;

    cout << "\nThe radius of circle is: " << radius << endl;

    fAreaCircle = (M_PI * radius) * radius;
    fCircumferenceCircle = (2.0 * M_PI) * radius;

    cout << "The area of the circle is: " << fAreaCircle << endl;
    cout << "The circumference of the circle is: " << fCircumferenceCircle << endl;

    system("Pause");
    return 0;
    }

  3. #3
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    thanks for sharing

  4. #4
    Junior Member shafiq856's Avatar
    Join Date
    Jul 2010
    Location
    Muzaffargarh
    Posts
    14

    18 Another Idea Solution CS201 Assignment 3 Spring 2011

    Another Idea Solution CS201 Assignment 3 Spring 2011


    #include <iostream>
    #include <cmath>
    #include <iomanip>
    using namespace std;
    #define PI 3.14
    class Circle
    {
    public:
    double radius;
    Circle();
    Circle(double);
    double calculateArea(double);
    double calculateCircum(double);
    void display();
    };
    Circle::Circle()
    {
    radius = 0;
    }
    Circle::Circle(double r)
    {
    radius = r;
    }
    double Circle::calculateArea(double r)
    {
    return (PI*r*r);
    }
    double Circle::calculateCircum(double r)
    {
    return (2*PI*r);
    }
    void Circle::display()
    {
    cout << "Radius of the Circle is " << Circle::radius << endl;
    cout << "Area of the Circle is " << calculateArea(Circle::radius) << endl;
    cout << "Circumference of the Circle is " << calculateCircum(Circle::radius) << endl << endl;
    }
    main()
    {
    Circle circle1;
    Circle circle2(3.5);
    circle1.display();
    circle2.display();
    system("pause");
    }
    Spring 2011_CS201_3 Solution.rar
    Attached Files Attached Files

  5. #5

  6. #6

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 01-31-2013, 03:11 PM
  2. Replies: 12
    Last Post: 12-27-2011, 05:44 PM
  3. Replies: 4
    Last Post: 07-03-2011, 04:42 AM
  4. Replies: 2
    Last Post: 06-08-2011, 05:55 PM
  5. Cs101 Assignment no 3 Spring 2011 Idea solution on 1 june
    By Ali-k in forum Get Solution In 24 Hour
    Replies: 2
    Last Post: 06-08-2011, 05:51 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft