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 Santosh Kumar Gadagamma

I'm Santosh Gadagamma, an Experienced Software Engineer passionate about sharing knowledge in technologies like Java, C/C++, DBMS/RDBMS, Bootstrap, Big Data, Javascript, Android, Spring, Hibernate, Struts, and all levels of software design, development, deployment, and maintenance. I believe computers are essential for the world's functioning, and I'm committed to helping others learn the skills they need to succeed in tech. My website is a valuable learning tool to help you reach greater heights in your education and career, and I believe that education has no end points.

Check Also

DAX Interview Questions

These are the mostly asked DAX Interview questions in and Power BI developer Interviews for …