Conversion of Time

import java.util.Scanner;

/* AniBlogger12
 * Program to convert elapsed time in the form of hours, minutes, seconds to seconds. 
 */
public class TP {

	public static void main(String[] args) {
		Scanner keyboard = new Scanner(System.in);
		System.out.println("Please enter the time as three integers: hours, minutes, and seconds");
// Define hours, minutes, and seconds	
		int hours = keyboard.nextInt();
		int minutes = keyboard.nextInt();
		int seconds = keyboard.nextInt();
//Convert hours to seconds: hours*3600= seconds
//Convert minutes to seconds: minutes*60=seconds
//Add hours+ minutes+seconds to get total seconds
		int total = hours * 3600 + minutes * 60 + seconds;
		System.out.println(hours + ":" + minutes + ":" + seconds + " elapsed time converts to " + total + " seconds.");
	}

}

Design a site like this with WordPress.com
Get started