At Westonci.ca, we provide clear, reliable answers to all your questions. Join our vibrant community and get the solutions you need. Get quick and reliable answers to your questions from a dedicated community of professionals on our platform. Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals.

(Hours, minutes, and seconds) Write a method that returns a string in the form of hour:minute:second for a given total seconds using the following header:
public static String format(long seconds)
Here is a sample run:

Enter total seconds: 342324
The hours, minutes, and seconds for total seconds 342324 is 23:05:24

Note that a zero is padded to hour, minute, and second if any of these values is a single digit.


Sagot :

Answer:

Answered below.

Explanation:

class Convert {

public static String format(long seconds) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter total seconds: ");

int secs = sc.nextInt();

int hours = secs / 3600;

int minutes = (secs % 3600) / 60;

int seconds = (secs % 3600) % 60;

String timeFormat = hours + ":" + minutes + ":" + seconds;

return timeFormat;

}

}

Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Thanks for stopping by. We strive to provide the best answers for all your questions. See you again soon. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.