Java program to convert hours to seconds


Following program shows you how to convert hours to seconds.
In this program we get hours from user, once we get those we need to multiply with 60 so that we get in minutes, and once we get minutes we need to multiply with 60 so that we get in seconds

import java.util.Scanner;

public class MathUnitConversions11 {

	public static void main(String[] args) {

		long hours;

		Scanner in = new Scanner(System.in);

		System.out.println("Please enter hours:");
		hours = in.nextInt();

		long seconds = hours * 60 * 60;

		System.out.println(seconds + " Seconds");

	}
}

Output:

Please enter hours:
5
18000 Seconds