| BSIT07-01 | 18-09-2008 05:01 AM | [Classes] Compre two distance values and display larger One Code:
#include
using namespace std;
class dist
{
private:
int feet;
int inches;
public:
int publicfeet;
float publicinches;
void getdist()
{
cout<<"\nEnter Feet : ";
cin>>feet;
cout<<"\nEnter Inches : ";
cin>>inches;
if(inches>=12)//It will correct the inches...
{
feet=feet+inches/12;
inches=inches%12;
cout<<"\nNote: The Distance Value is corrected to "<
}
}
void largedist(dist a, dist b)
{
if(a.feet>b.feet)
{feet=a.feet;
inches=a.inches;
}
else if (a.feet
{ feet=b.feet;
inches=b.inches;
}
else if(a.feet==b.feet)
{
if(a.inches>b.inches)
{feet=a.feet;
inches=a.inches;}
else if(a.inches
{
feet=b.feet;
inches=b.inches;
}
}
cout<<"\nLarger distace = "<
}
};
void main()
{
dist a,b,larger;
a.getdist();
b.getdist();
larger.largedist(a,b);
} |