Answer:
hope this helps.
Step-by-step explanation:
import java.util.*;
class Timeconvert{ //class nane
public static String convertTime(int totalSeconds) /* fn to convert seconds to hh:mm:ss format */
{
int sec = totalSeconds; // a copy of totalSeconds is stored in sec
int m=sec/60; //to find the total min which obtained by doing sec/60
int psec=sec%60; //psec store remaining seconds
int hrs=m/60; //stores hr value obtained by doing m/60
int min=m%60; //stores min value obtained by m%60
return (hrs + ":" + min+ ":" +psec);// returning that string
}
}
public class Main
{
public static void main(String[] args) {
Timeconvert t = new Timeconvert();
Scanner in = new Scanner(System.in); //Scanner class
System.out.println("Enter the number of seconds:");
int sec = in.nextInt(); //to input number of seconds
System.out.println("hours:minutes:seconds is " + t.convertTime(sec)); //result
}
}