Search This Blog

Wednesday, December 29, 2010

OBJECTS AS PARAMETERS IN FUNCTIONS

public class time
{
    int hr, min;
    int totalhours, totalminutes;
    void input(int h, int m)
    {
        hr=h;
        min=m;
    }
    void addtime(time t1, time t2)
    {
        totalhours= t1.hr + t2.hr + (t1.min + t2.min)/60;
        totalminutes=(t1.min + t2.min)%60;
    }
   
    void display()
    {
        System.out.println(totalhours + " hrs " + totalminutes +" min " );  
    }
}

No comments:

Post a Comment