Write a program in Java that accepts the seconds as input and converts them into the corresponding number of hours, minutes and seconds. A sample output is shown below: Enter Total Seconds: 5000 1 Hour(s) 23 Minute(s) 20 Second(s)
import java.util.*;
class q4
{
public static void main(String args[ ])
{
Scanner sc=new Scanner(System.in);
System.out.println("ENTER TIME IN SECONDS");
int t=sc.nextInt();
int m=t/60;
int h=m/60;
m=m%60;
int s=t%60;
System.out.print(" hour="+h);
System.out.print(" minutes="+m);
System.out.print(" seconds="+s);
}
}
PROGRAM :


Comments
Post a Comment