Java program to convert days to seconds

Views: 85   

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

import java.util.Scanner;

public class MathUnitConversions13 {

    public static void main(String[] args) {

        long days;

        Scanner in = new Scanner(System.in);

        System.out.println("Please enter days:");
        days = in.nextLong();

        long seconds = days * 24 * 60 * 60;

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

    }
}

Output:

Please enter days:
3
259200 Seconds
On By