Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static Scanner console = new Scanner(System.in);
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args){
- int seconds;
- int minutes;
- int hours;
- int time;
- System.out.println("Enter how many seconds the event took:");
- time = console.nextInt();
- //Received input in seconds.
- //3600 seconds = 1 hour
- //60 seconds = 1 minute
- System.out.println(time + " seconds?");
- System.out.println("Alright, let's do this!");
- hours = (int) Math.floor(time / 3600);
- minutes = (int) Math.floor((time - (hours * 3600)) / 60);
- seconds = (time - ((hours * 3600) + (minutes * 60)));
- System.out.println(hours + ":" + minutes + ":" + seconds);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment