We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs / Quizzes files as you receive in your LMS, So it can be discussed/solved timely. Add Discussion

How to Add New Discussion in Study Group ? Step By Step Guide Click Here.


 

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:

 

  •  
    • One using default constructor
    • 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:

 

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.





 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 220

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

please discus it here

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;

}

 

But in in your provided solution, program is not asking for radius.

In instruction radius 3.5 is a sample output.

Sorry, Bhai Adnan Ayub ke solution mein execute kartay hoye thori si problem hai.

Correct solution is

#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");

}

 

Correct Solution is attached
Attachments:

which one is correct............ any one explain?

Correct Solution is attached
Attachments:
which one is correct? :(

CS201 Assingment no 3 Solution Spring 2011

See the attached file please

Attachments:

CS201 Assignment No. 3 solution



#include<iostream.h>
#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");
}
CS201 Assignment No. 3 solution



#include<iostream.h>
#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");
}


#include<iostream.h>
#include <cmath>
#include <iomanip>
using namespace std;

#define PI 3.14 //definig the macro for PI

class circle //declaration of the class
{

private: 
public: //radius objects are public 

float radius;
circle();
circle(float);
float circlearea(float);
float circlecircumference(float);
void display();
};

circle::circle() 
{
radius=0;
}
circle::circle(float i)
{
radius=i;
}
float circle::circlearea (float i)
{
return (PI*i*i);
}

float circle::circlecircumference (float i)
{
return (2*PI*i);
}
void circle::display()
{
cout"radius of the circle is="circle::radiusendl;
cout"Area of the circle is=" circlearea(circle::radius)endl;
cout"circumference of the circle is "circlecircumference(circle::radius)endl;
}

main()
{
circle circle1;
circle circle2(3.5);
circle1.display();
circle2.display();
}

RSS

Today Top Members 

© 2020   Created by +M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service

.