In this post you can learn to convert hours into minutes using the java program. The steps are given below
- At the first step create the java file with the main class.
- At the next step declare the hour and minutes in integer.
- Then use the scanner method and get the hour as an input.
- Use the formula to convert hours to second.
- At next use the printer statement to print the output.
Hours to Minutes Formula:
minutes=hours*60;
Program to convert hours to minutes in java:
import java.util.Scanner;
class hours{
public static void main(String args[]){
int hours,minutes;
Scanner sc=new Scanner(System.in);
hours=sc.nextInt();
minutes=hours*60;
System.out.println("Minutes = "+minutes);
}
}
Input:
2
Output:
Minutes = 120
Post a Comment