2. Write a program in java that accepts the seconds as input and converts them into the corresponding number of hours
minutes and seconds.
Share
2. Write a program in java that accepts the seconds as input and converts them into the corresponding number of hours
minutes and seconds.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Answer:
import java.util.*;
public class Question {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Time in seconds: ");
int seconds = in.nextInt();
int s = seconds % 60;
int h = seconds / 60;
int m = h % 60;
h = h / 60;
System.out.print( h + " Hour " + m + " Minutes " + s+ " Seconds");
System.out.print("\n");
}
}