Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. package Questions;
  2. import java.util.Scanner;
  3. public class Q1 {
  4.  
  5. public static void main(String[] args) {
  6. Scanner input = new Scanner(System.in);
  7. System.out.println("Enter time in seconds: ");
  8. int seconds = input.nextInt();
  9. public static String convertTime(int totalSeconds){
  10. int hours = totalSeconds / (60*60);
  11. totalSeconds -= hours*60*60;
  12. int minutes = totalSeconds/60;
  13. totalSeconds -= minutes*60;
  14. String.format("%01d:%01d:%01d",hours, minutes, seconds);
  15. System.out.println(String.format("%01d:%01d:%01d",hours, minutes, seconds));
  16.  
  17. }
  18.  
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement