Science, asked by dishamalhan325, 3 months ago

4.Wap to input time in seconds. Display time after converting them into hours, minutes and seconds.

I need the variable description of this Java programs plss help me asap
and don't spam plsss

Answers

Answered by DATTASABYASACHI1269
1

/* WAP TO PRINT THE TIME IN HH:MM:SS FORMAT AFTER ADDITION OF TWO TIMES. INPUT SHOULD BE USING CONSTRUCTOR */

class Time

{

int hr,min,sec,day=0;

Time(int hr1,int min1,int sec1)

{

 hr=hr1;

 min=min1;

 sec=sec1;

}

void display()

{

 System.out.println("time is :"+day+" day  "+hr+"Hour:"+min+"Minute:"+sec+"Second");

}

void manipulate()

{

 while(hr>24)

 {

  hr=hr-24;

  day++;

 }

 while(min>60)

 {

  min=min-60;

  hr++;

  while(hr>24)

  {

   hr=hr-24;

   day++;

  }

 }

 while(sec>60)

 {

  sec=sec-60;

  min++;

  while(min>60)

  {

   min=min-60;

   hr++;

   while(hr>24)

   {

    hr=hr-24;

    day++;

   }

  }

 }

}

void add(Time ob1,Time ob2)

{

 hr= ob1.hr+ob2.hr;

 min=ob1.min+ob2.min;

 sec=ob1.sec+ob2.sec;

 

}

}

class TimeAdditionConstructor

{

public static void main(String args[])

{

 Time ob= new Time(35,12,80);

 Time ob1= new Time(16,23,67);

 ob.add(ob,ob1);

 ob.manipulate();

 ob.display();  

}

}

Answered by MangekyoSharingan344
1

Java is a widely used object-oriented programming language and software platform that runs on billions of devices, including notebook computers, mobile devices, gaming consoles, medical devices and many others. The rules and syntax of Java are based on the C and C++ languages

Similar questions