You are on page 1of 5

Usama Ikram

287883
DEE 41 (c)

TASK 1
#include <iostream>
#include<math.h>
using namespace std;

class Point
{
private:
double x1, y1;

public:
Point()
//constructor Test
{
x1 = 0;

y1 = 0;
}

// Parameterized Constructor
Point(int x, int y)
{
x1 = x;
y1 = y;
}

//Input
void coord()
{
//Static Data Member
static int coord = 0;
coord = coord + 1;
cout << "Point Number " << coord << endl;

}
void InputX1()
{
cout << "Enter X Coordinate \n";
cin >> x1;
}

void InputY1()
{
cout << "Enter Y Coordinate \n";
cin >> y1;
}

void Out1()
{

cout << endl << "Point 1 Coordinates are " << "(" << x1 << "," << y1 << ") \n";

void Dist()
{
float Dist, x2, y2, a, b = 0;
cout << "\nEnter Point 2 For calculating Distance" << endl;
cout << "Enter X Coordinate \n";
cin >> x2;

cout << "Enter Y Coordinate \n";


cin >> y2;

a = pow((x2 - x1), 2);


b = pow((y2 - y1), 2);
Dist = pow((a + b), 0.5);

cout << endl << "Distance Between the Two Points is \n";
cout << Dist << endl;
}
void cent() //Center
{
if (x1 == 0 && y1 == 0)
{
cout << endl << "The Entered Coordinates are in the Center\n";
}
else
{
cout << endl << "The Entered Coordinates are not in the Center\n";
cout << endl;
}
}
void mid() //mid
{
double a, b, c, d;
cout << endl << "Enter Coordinates to find MidPoint\n";
cout << "Enter X Coordinate\n";
cin >> a;
cout << "Enter Y Coordinate\n";
cin >> b;
c = (a + x1) / 2;
d = (b + y1) / 2;
cout << "Midpoint of the given Coordinates is \n";
cout << "(" << c << "," << d << ")";
cout << endl;

void eq() // equality


{
int a;
int b;
bool p;
cout << "\nEnter the coordinates to check equality\n" << "X Coordinate\n";
cin >> a;
cout << "Y coordinate\n";
cin >> b;
if (a == x1 && b == y1)
{
p = true;
cout << "They are Equal\n";
}
else
{
p = false;
cout << "They are not Equal\n\n";
}
}

void comp()
{
int a;
int b;
float xy;
float ab;
float dist;
float yx;
float xyo;
float disto;
cout << "\nEnter a point to compare with (x,y)";
cout << endl << "Enter X Coordinate\n";
cin >> a;
cout << "Enter Y Coordinate\n";
cin >> b;
dist = (a ^ 2) + (b ^ 2);
disto = pow(dist, 0.5); //Distance of Entered Points from Origin
xy = pow(x1, 2);
yx = pow(y1, 2);
xyo = pow((xy + yx),0.5); //Distance of xy from origin
if (disto >xyo )
{
cout << "\nEntered points have greater distance from origin than (x,y)\n";
}
else if (xyo < disto)
{
cout << "\n(x,y) is at greater distance from Origin than the Entered
Points\n";
}
else if (disto = xyo)
{
cout << "\nBoth points are Equidistant from the Origin\n";
}
}

};

int main()
{
Point a;
a.coord();
a.InputX1();
a.InputY1();
a.Out1();
a.Dist();
a.mid();
a.eq();
a.comp();

system("Pause");
return 0;

TASK 2
#include<iostream>
using namespace std;
//Create a class Job..
class Job
{

//Declare jobId as a static data member


public:
int deadline;
int profit;
bool check;
int id;
//adding static variable
static int jobId;
//Default constructor for Job that increases jobId by 1 at ever time creation of new
objects
Job()
{
jobId++;
}
};
//Removing Garbage value
int Job::jobId = 0;
int main()
{
int dead, prof, totalProfit = 0;
int x = 0;

bool status = 0;
//To take total number of jobs from user
cout << "Enter total number of jobs\n";
cin >> x;
//Create an object array of type Job..
Job obj[x];
for (int i = 0;i < x;i++)
{
cout << "\nEnter Deadline of job No. " << (i + 1);
cout << endl;
cin >> dead;
obj[i].deadline = dead;
cout << "\nEnter the Profit of job No. " << (i + 1);
cout << endl;
cin >> prof;
obj[i].profit = prof;
cout << "\nEnter 1 if submitted on time\n" << "Otherwise Enter 0\n";
cin >> status;
obj[i].check = status;

if (obj[i].check == true)
{
totalProfit += obj[i].profit;
}
//set the id for each job object to (i+1)
obj[i].id = (i + 1);
}
//Print the output
cout << "\nPrinting the given info\n\n"; cout << "Total Job Id's available in the
Job : "
<< obj[0].jobId << "\n";

for (int i = 0;i < x;i++)


{
cout << "Deadline for job No. " << (i + 1) << endl;
cout << obj[i].deadline << "\n";
if (obj[i].check == true)
{
cout << "Job " << (i + 1) << " is submitted on time\n";
}
else
{
cout << "Job " << (i + 1) << " is not submitted on time\n";
}
}
cout << "Total Profit is \n" << totalProfit;
system("pause");
return 0;
}

You might also like