HOW TO CONVERT HOURS TO MINUTES IN JAVA


 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

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post