Professional Documents
Culture Documents
Solution Lab
Solution Lab
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 << 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 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
{
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";