seconds to hours and minutes
seconds to hours and minutes

Java Programs

Write a java program to accept seconds as an input and convert into hours and minutes?

import java.util.*;
public class timeConvert {
int sec=0,min=0,hr=0;
int reminder=0;
Scanner sr = new Scanner(System.in);
public timeConvert(){
System.out.println(“Enter seconds to convert”);
sec=sr.nextInt();
if(sec!=0){
min=sec/60;
reminder=sec%60;
sec=reminder;
if(min>=60){
hr=min/60;
min=min%60;
}
}
System.out.println(hr+”Hours:”+min+”Minutes:”+sec+”Seconds”);
}
public static void main(String args[]){
timeConvert tc = new timeConvert();
tc.getClass();
}

}

seconds to hours and minutes
seconds to hours and minutes

 

About GSK

Hi, i am Santosh Gadagamma, a tutor in Software Engineering and an enthusiast for sharing knowledge in Computer Science and other domains. I developed this site to share knowledge to all the aspirants of technologies like, Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts and all levels of software project design, development, deployment, and maintenance. As a programmer I believe that, "The world now needs computers to function." Hope, this site guides you as a learning tool towards greater heights. I believe that Education has no end points and i wish to learn more in the process of teaching you.

Check Also

Interview Stuff

C ++ Interview Questions Q1).State the different types of linked lists? ANS). The different types …