How to convert minutes to seconds

 

how to convert minutes to seconds
Convert minutes to seconds using the java program. The steps are given below and can leran it.
  • Create a java file and create the main function.
  • Then use the minutes, second and hours variable.
  • The above three variable are declared in integer.
  • Then get the minutes input from the user.
  • To get the in put from the user use Scanner.
  • After getting the minute as a input then convert minutes to hours

minutes to hour formula:

hours=minutes/60

hours to seconds formula:

seconds=hours*3600

  • Using the print statement show the output.

java program to convert minutes to seconds:

file name: Seconds.java

import java.util.Scanner;

class Seconds{
    public static void main(String args[]){
        int minutes,seconds,hours;
        Scanner sc=new Scanner(System.in);
        minutes=sc.nextInt();
        hours=minutes/60;
        seconds=hours*3600;
        System.out.println(seconds);
    }
}

input:

300

output

1800

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post