Looking for reliable answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Explore thousands of questions and answers from a knowledgeable community of experts on our user-friendly platform. Get immediate and reliable solutions to your questions from a community of experienced professionals on our platform.
Sagot :
Answer:
hope this helps.
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
}
}
Thank you for visiting our platform. We hope you found the answers you were looking for. Come back anytime you need more information. We appreciate your time. Please come back anytime for the latest information and answers to your questions. Stay curious and keep coming back to Westonci.ca for answers to all your burning questions.