turt2live

Untitled

Mar 6th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     static Scanner console = new Scanner(System.in);
  5.  
  6.     /**
  7.      * @param args the command line arguments
  8.      */
  9.     public static void main(String[] args){
  10.         int seconds;
  11.         int minutes;
  12.         int hours;
  13.         int time;
  14.  
  15.         System.out.println("Enter how many seconds the event took:");
  16.  
  17.         time = console.nextInt();
  18.         //Received input in seconds.
  19.         //3600 seconds = 1 hour
  20.         //60 seconds = 1 minute
  21.         System.out.println(time + " seconds?");
  22.         System.out.println("Alright, let's do this!");
  23.         hours = (int) Math.floor(time / 3600);
  24.         minutes = (int) Math.floor((time - (hours * 3600)) / 60);
  25.         seconds = (time - ((hours * 3600) + (minutes * 60)));
  26.         System.out.println(hours + ":" + minutes + ":" + seconds);
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment