Java program to convert days to hours

Views: 96   

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

import java.util.Scanner;

public class MathUnitConversions10 {

    public static void main(String[] args) {

        long days;

        Scanner in = new Scanner(System.in);

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

        long hours = days * 24;

        System.out.println(hours + " Hours");

    }
}

Output:

Please enter days:
20
480 Hours
On By