BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan

BZU PAGES: Find Presentations, Reports, Student's Assignments and Daily Discussion; Bahauddin Zakariya University Multan (http://bzupages.com/)
-   Object Oriented Programming (http://bzupages.com/35-object-oriented-programming/)
-   -   [Classes] Compre two distance values and display larger One (http://bzupages.com/f35/%5Bclasses%5D-compre-two-distance-values-display-larger-one-746/)

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);   
}



All times are GMT +5. The time now is 11:09 AM.

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.