/* Program to add two distances, one in 'feet,inches' and other in 'meter and centimeter' and display the result in fact,inches*/

| |


#include<iostream.h>
#include<conio.h>
class mtrcm;
class dist
{
int feet; float inch;
public:
dist()
{
feet=inch=0;
}
dist(int f,float in)
{
feet=f;inch=0;
}
void show()
{
cout<<feet<<inch;
}
friend void add(dist,mtrcm);
};
class mtrcm
{
int mtr,cm;
public:
mtrcm(int m,int c)
{
mtr=m;cm=c;
}
friend void add(dist,mtrcm);
};
void add(dist dd, mtrcm mm)
{
float distfeet=dd.feet+dd.inch/12;
float distmtrcm=(mm.mtr+mm.cm/100)*3.28;
float distaddfeet=distfeet+distmtrcm;
dist res;
res.feet=int(distaddfeet);
res.inch=(distaddfeet-res.feet)*12.00;
cout<<"\nfeet="<<res.feet<<"\ninches="<<res.inch;
}
int main()
{
dist d1(2,0);
mtrcm m1(1,100);
add(d1,m1);
return 0;
}
<