#include<iostream>
using namespace std;
class Distance
{
private:
int feet;
float inches;
public:
Distance()
{
feet=0;
inches=0;
}
Distance(int f , float in)
{
feet=f;
inches=in;
}
void get_Dist()
{
cout<<"enter feet =";
cin>>feet;
cout<<"enter inches =";
cin>>inches;
}
void disp_Dist()
{
cout<<" Distancee = "<<feet<<"\'_ "<<inches<<"\''"<<endl;
}
Distance operator -(Distance d5)
{
int f;
float i;
float i2=feet*12+inches;
float i1=d5.feet*12+d5.inches;
if(i2<i1)
{
f=0;
i=0;
}
else
{
if(inches<d5.inches)
{
inches+=12;
feet--;
}
f=feet-d5.feet;
i=inches-d5.inches;
while(i>=12)
{
i-=12;
f++;
}
}
return Distance(f,i);
}
};
int main()
{
Distance d1,d2(5,2);
d1.get_Dist();
Distance d3=d2-d1;
d3.disp_Dist();
system("pause");
}
using namespace std;
class Distance
{
private:
int feet;
float inches;
public:
Distance()
{
feet=0;
inches=0;
}
Distance(int f , float in)
{
feet=f;
inches=in;
}
void get_Dist()
{
cout<<"enter feet =";
cin>>feet;
cout<<"enter inches =";
cin>>inches;
}
void disp_Dist()
{
cout<<" Distancee = "<<feet<<"\'_ "<<inches<<"\''"<<endl;
}
Distance operator -(Distance d5)
{
int f;
float i;
float i2=feet*12+inches;
float i1=d5.feet*12+d5.inches;
if(i2<i1)
{
f=0;
i=0;
}
else
{
if(inches<d5.inches)
{
inches+=12;
feet--;
}
f=feet-d5.feet;
i=inches-d5.inches;
while(i>=12)
{
i-=12;
f++;
}
}
return Distance(f,i);
}
};
int main()
{
Distance d1,d2(5,2);
d1.get_Dist();
Distance d3=d2-d1;
d3.disp_Dist();
system("pause");
}
0 comments:
Post a Comment