# CS201 Assignment 3 Solution 2021 - VU Answer In This Post, Provide CS201 Assignment 3 Solution Spring 2021. Complete Step by Step CS201 Assignment 3 Solution 2021. Easy to Download Assignment Solution File Give Below in .cpp, Word, and PDF File.

CS201 ASSIGNMENT 3 SOLUTION SPRING 2021

Assignment Objective

To enable students to understand and practice the concepts of:

• Classes and their structure.

• Data Members and Member functions of the class.

• The constructor of the class.

Code result screenshot is given below

Solution Code:

#include <iostream>

using namespace std;

#define PI 3.14159265

class Circle

{

private:

public:

void computeAreaCirc();

Circle();

~Circle();

};

Circle::Circle()

{

}

{

}

void Circle::computeAreaCirc()

{

cout << "Area of circle is: " << PI * (radius * radius) << endl;

cout << "Circumference of circle is: " << 2 * PI * radius << endl;

}

Circle::~Circle()

{

}

class Rectangle

{

private:

double length;

double width;

public:

void setLength();

void setWidth();

void computeArea();

Rectangle();

~Rectangle();

};

Rectangle::Rectangle()

{

length = 0.0;

width = 0.0;

}

void Rectangle::setLength()

{

length = 5.0;

}

void Rectangle::setWidth()

{

width = 4.0;

}

void Rectangle::computeArea()

{

cout << "Area of Rectangle: " << length * width << endl;

}

Rectangle::~Rectangle()

{

}

main()

{

cout<<"********************SCIENTIFIC CALCULATOR********************"<<endl;

cout<<""<<endl;

int run = 1;

string option, choice;

while(run)

{

cout << "\nOPTION 1 for computing Area and Circumference of the circle" << endl;

cout << "OPTION 2 for computing Area of the Rectangle" << endl;

cout << "Select your desired option(1-2): ";

cin >> option;

if(option == "1")

{

Circle nCircle;

nCircle.computeAreaCirc();

cout << "Do you want to perform anyother calculation(Y/N):";

cin >> choice;

if(choice == "Y" || choice == "y")

{

continue;

}

else

{

break;

}

}

else if(option == "2")

{

Rectangle nRectangle;

nRectangle.setLength();

nRectangle.setWidth();

nRectangle.computeArea();

cout << "Do you want to perform anyother calculation(Y/N):";

cin >> choice;

if(choice == "Y" || choice == "y")

{

continue;

}

else

{

break;

}

}

else

{

cout << "Invalid Option!, Option should be from (1-2)" << endl;

}

}

}

CODE RESULT 