0% found this document useful (0 votes)
32 views

Assignment 1 OOP 1

This document contains an assignment submission for an Object Oriented Programming lab course. The assignment includes 4 tasks involving classes and objects to calculate areas and perimeters of shapes like rectangles, circles, and colors. Code snippets are provided for each task that demonstrate class definitions and use of methods to output calculated values. The submission includes the student's name, ID, section, and is due to their professor by a specified date.

Uploaded by

HUZAIFA SAEED
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Assignment 1 OOP 1

This document contains an assignment submission for an Object Oriented Programming lab course. The assignment includes 4 tasks involving classes and objects to calculate areas and perimeters of shapes like rectangles, circles, and colors. Code snippets are provided for each task that demonstrate class definitions and use of methods to output calculated values. The submission includes the student's name, ID, section, and is due to their professor by a specified date.

Uploaded by

HUZAIFA SAEED
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Course Tittle:

Object Oriented Programming (LAB)

Course Code:

CC 1022L

Assignment Topic : “Assignment 1”


Due Date for Submission : “Wednesday, 17-03-2021”
Submitted to : “Muhammad Imran Khalil”
Assistant Professor
School of Systems And Technology (SST)

Name : Huzaifa Saeed


Student Id : F2020266522
Section : V2
BSCS (Computer Sciences)
TASK 1:

#include <iostream>
using namespace std;
class Rectangle
{
private:
double length;
double width;
public:
void setlength(double l)
{
length = l;
}
double getlength()
{
return length;
}
void setwidth(double w)
{
width = w;
}
double getwidth()
{
return width;
}
double area()
{
double perimeter = 2 * length + 2 * width;
return perimeter;
}
int perimeter()
{
int area = length * width;
return area;
}
};
int main()
{
Rectangle r1;
r1 . setlength(6.25);
r1 . setwidth(8.2);
cout << "The Area of the Rectangle is: " << r1.area() << endl;
cout << "The Perimeter of the Rectangle is: " << r1.perimeter() << endl;
return 0;
}

Output:

TASK 2:

#include <iostream>
using namespace std;
class color
{
public:
int r;
int g;
int b;
string CLR;
color(int R=0, int G=0, int B=0, string clr="White")
{
r = R;
g = G;
b = B;
CLR = clr;
}
void display()
{
cout << r << " " << g << " " << b << " " << CLR << endl;
}
};
int main()
{
color c1(1, 2, 3, "Black");
color c2;
c1.display();
c2.display();
return 0;
}

Output:

TASK 3:

#include <iostream>
using namespace std;
class Student
{
public:
int english;
int oop;
int discrete_structures;
int calculus;
int islamiyat;
Student (int eng = 78, int op = 86, int disc = 100, int cal = 98, int islam = 50)
{
english = eng;
oop = op;
discrete_structures = disc;
calculus = cal;
islamiyat = islam;
}
void display ()
{
cout << "The number of Subject English are: " << english << endl;
cout << "The number of Subject Object-Oriented Programming are: " << oop << endl;
cout << "The number of Subject Discrete Structures are: " << discrete_structures << endl;
cout << "The number of Subject Calculus are: " << calculus << endl;
cout << "The number of Subject Islamiyat are: " << islamiyat << endl << endl;
}
};
int main()
{
Student s1(51, 52, 53, 54, 54);
s1.display();
Student s2;
s2.display();
Student s3(70, 65, 92, 49, 38);
s3.display();
return 0;
}

Output:

TASK 4:

#include <iostream>
using namespace std;
class Circle
{
public:
double radius;
Circle (double r)
{
radius = r;
}
double getarea ()
{
double area1 = 3.14 * (radius * radius);
return area1;
}
double getperimeter ()
{
double perimeter = 2 * (3.14 * radius);
return perimeter;
}
};
int main()
{
Circle c1(4);
cout << "The area of Circle is: " << c1.getarea() << endl;
cout << "The perimeter of the Circle is: " << c1.getperimeter() << endl << endl;
Circle c2(9);
cout << "The area of Circle is: " << c2.getarea() << endl;
cout << "The perimeter of the Circle is: " << c2.getperimeter();
return 0;
}

Output:

You might also like