Ask your own question, for FREE!
Computer Science 12 Online
OpenStudy (anonymous):

Java: I'm attempting to take a time value in seconds, namely 8732 seconds, and convert it into hr:min:sec format. This is what I have so far. Ideas? I'm sort of lost. public class Time { public static void main(String args[]){ int total_seconds = 8732; int total_minutes = total_seconds / 60; int hours = total_minutes / 60; int minutes = total_minutes - hours * 60; System.out.println(hours + ":" + minutes + ":" + seconds); }}

OpenStudy (anonymous):

Note that I have yet to define "seconds" in my s.o.p

OpenStudy (anonymous):

Disregard, solved //Seconds we need to divide between hours, min, and sec int total_seconds = 8732; //The number of whole minutes in our 8732 seconds int total_minutes = total_seconds / 60; //The number of whole hours in our total_minutes int hours = total_minutes / 60; // int minutes = total_minutes - hours * 60; int seconds_accounted_for = (hours * 60) * 60 + minutes * 60; int seconds = total_seconds - seconds_accounted_for; System.out.println(hours + ":" + minutes + ":" + seconds);

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!