View Single Post
  #1  
Old 18-09-2008, 05:01 AM
BSIT07-01's Avatar
BSIT07-01 BSIT07-01 is offline
Addicted to Computer


 
Join Date: Sep 2007
Location: ------------
Age: 36
Posts: 1,309
Contact Number: ---------------
Program / Discipline: BSIT
Class Roll Number: 07-01
BSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant futureBSIT07-01 has a brilliant future
Default [Classes] Compre two distance values and display larger One

Code:
#include <iostream>
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 "<<feet<<"\""<<inches<<"\'\n";

    }
    }


    void largedist(dist a, dist b)
{
    
    if(a.feet>b.feet)
    {feet=a.feet;
        inches=a.inches;
    }
    else if (a.feet<b.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<b.inches)
        {
            feet=b.feet;
        inches=b.inches;
        }
    }
    
    cout<<"\nLarger distace = "<<feet<<"\""<<inches<<"\'";
}    
};

    
void main()
{
    dist a,b,larger;
    a.getdist();
    b.getdist();
    larger.largedist(a,b);    
}

Reply With Quote