11. JAVA Program to convert Seconds into Hours and Minutes.
How does this program work?
- In this programme you will learn about how to convert Seconds into Hours and Minutes.
- First user has to Enter how many seconds that to convert.
- This programme perform mathematical calculation and display the result using C language.
Here is the code
//To convert seconds into hours and minutes
import java.util.Scanner;public class Seconds
{
public static void main(String[] args)
{
int seconds;
// Enter the seconds here.
System.out.print("Enter seconds: \n" );// Create object of scanner class.
Scanner obj = new Scanner(System.in);seconds =obj.nextInt();
int p1 = seconds % 60;
int p2 = seconds / 60;
int p3 = p2 % 60;
p2 = p2 / 60;
System.out.println("convert Hours:Minutes:Seconds is:\n");
System.out.print("HH:MM:SS :" +p2 + ":" + p3 + ":" + p1);
System.out.print("\n");
}
}