Write a Java program to convert seconds to hour, minute and seconds


Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. import java.util.*;
  2. public class Javaexcercise {
  3. public static void main(String[] args)
  4. {
  5. Scanner in = new Scanner(System.in);
  6. System.out.print("Enter seconds: ");
  7. int seconds = in.nextInt();
  8. int a = seconds % 60;
  9. int b = seconds / 60;
  10. int c = b % 60;
  11. b = b / 60;
  12. System.out.print( b + ":" + c + ":" + a);
  13. System.out.print("\n");
  14. }
  15. }

Result

java techstudy.org

     





Related Topics




Popular Posts