write a program to input the time in second display the time after converting them into hours, minutes and second
sample input : time in second 5420
sample output: 1 hour 30 minutes 20 second
Answers
Answer:
function (sec) {
var sec_num = parseInt(sec)
var hours = Math.floor(sec_num / 3600);
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
var seconds = sec_num - (hours * 3600) - (minutes * 60);
if (hours < 10) {hours = "0"+hours;}
if (minutes < 10) {minutes = "0"+minutes;}
if (seconds < 10) {seconds = "0"+seconds;}
return hours+ ' hrs'+':'+minutes+' min'+':'+seconds+' sec';
}
console.log(sec(100))
returns 0 hrs: 1 min: 40 sec
Answer:
import java.util.*;
Public Class Seconds
{
public static void main(String args [] )
{
Scanner in = new Scanner ( System.in);
System.out.println(" time in seconds");
Float seconds = in.next float();
Float hours= seconds / 3600;
Float mins = seconds /60;
Float seconds= S %60;
System.out.println( "hrs"+hours "minutes"+ mins "seconds"+seconds);
}
}
Explanation:
This is the write answer not the previous one (Trust me)