# Java Program to Convert Minute to Hour and Hour to Minute

In the previous article we have discussed about Java Program to Convert Minute to Millisecond, Microsecond and Vice Versa

In this article we will see how to convert Minute to Hour and Hour to Minute by using Java programming language.

## Java Program to Convert Minute to Hour and Hour to Minute

Before jumping into the program let’s know the relationship between Minute and Hour and how we can convert Minute to Hour and vice versa.

Minute and Hour are used as unit of time.

1 Hour = 60 Minute
1 Minute = 0.0166667 Hour

Formula to convert Minute to Hour.

Hour = Minute / 60

Formula to convert Hour to Minute.

Minute = Hour * 60

Let’s see different ways to convert Minute to Hour and Hour to Minute.

### Method-1: Java Program to Convert Minute to Hour and Hour to Minute By Using Static Input Value

Approach:

• Declare Minute and Hour value.
• Then convert Minute to Hour and Hour to Minute by using the formula.
• Print result.

Program:

import java.util.*;
public class Main
{
public static void main(String args[])
{
//Scanner class object created
Scanner sc=new Scanner(System.in);
//value of minute declared
double minute = 1;
//value of hour declared
double hour = 1;

//converting minute to hour
double hr = minute/60;
//converting hour to minute
double min = hour*60;
//printing result
System.out.println("Value of "+minute+" minute in hour: "+ hr);
System.out.println("Value of "+hour+" hour in minute: "+ min);
}
}
Output:

Value of 1.0 minute in hour: 0.016666666666666666
Value of 1.0 hour in minute: 60.0


### Method-2: Java Program to Convert Minute to Hour and Hour to Minute By Using User Input Value

Approach:

• Take user input of Minute and Hour value.
• Then convert Minute to Hour and Hour to Minute by using the formula.
• Print result.

Program:

import java.util.*;
public class Main
{
public static void main(String args[])
{
//Scanner class object created
Scanner sc=new Scanner(System.in);
//Taking the value input of double variable minute
System.out.println("Enter value of minute: ");
double minute = sc.nextDouble();
//Taking the value input of double variable hour
System.out.println("Enter value of hour: ");
double hour = sc.nextDouble();

//converting minute to hour
double hr = minute/60;
//converting hour to minute
double min = hour*60;
//printing result
System.out.println("Value of "+minute+" minute in hour: "+ hr);
System.out.println("Value of "+hour+" hour in minute: "+ min);
}
}
Output:

Enter value of minute:
180
Enter value of hour:
2
Value of 180.0 minute in hour: 3.0
Value of 2.0 hour in minute: 120.0


### Method-3: Java Program to Convert Minute to Hour and Hour to Minute By Using User Defined Method

Approach:

• Take user input of Minute and Hour value.
• Call a user defined method by passing Minute and Hour value as parameter.
• Inside method convert Minute to Hour and Hour to Minute by using the formula.
• Print result.

Program:

import java.util.*;
public class Main
{
public static void main(String args[])
{
//Scanner class object created
Scanner sc=new Scanner(System.in);
//Taking the value input of double variable minute
System.out.println("Enter value of minute: ");
double minute = sc.nextDouble();
//Taking the value input of double variable hour
System.out.println("Enter value of hour: ");
double hour = sc.nextDouble();
//calling user defined method convert()
convert(minute, hour);
}

//convert() method to convert minute to hour and vice versa
public static void convert(double minute, double hour)
{

//converting minute to hour
double hr = minute/60;
//converting hour to minute
double min = hour*60;
//printing result
System.out.println("Value of "+minute+" minute in hour: "+ hr);
System.out.println("Value of "+hour+" hour in minute: "+ min);
}
}
Output:

Enter value of minute:
120
Enter value of hour:
5
Value of 120.0 minute in hour: 2.0
Value of 5.0 hour in minute: 300.0


The best and excellent way to learn a java programming language is by practicing Simple Java Program Examples as it includes basic to advanced levels of concepts.

Related Java Programs: