Sunday, 5 November 2017

java programm convert seconds into hour mintue and seconds



Problem 03:
Write a program that ask the user to enter the time in seconds and convert into hour minute and seconds..
Description:
By using the remainder operator 
Solution
import java.util.*;
public class Message {
 public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long  s,h,m;
    System.out.println("Enter the time in seconds");
    s=in.nextInt();
    h=s/3600;
    s%=3600;
    m=s/60;
    s%=60;
   System.out.println("The  time is  ="+h +" HH      "+m+" MM     "+s+" SS");
 }
}

Output
                    

No comments:

Post a Comment