Java program to input in the time i seconds display the time after converting them into hours minutes and seconds write the program
Answers
Answer:
by the help of spread sheet
Answer:class time
{
public static void main(int seconds)
{
int hr,min,sec;
hr =seconds/3600;
min=seconds/60;
sec=min*60;
System.out.println("Hours="+hr);
System.out.println("Minutes="+min);
System.out.println("Seconds="+sec);
}
}
Explanation:
First we take seconds as user input the value the user will put as seconds will be used. Then we took input of variables like hr representing hour and min and sec as likely. In hr we calculate seconds that will be given by user divided by 3600 as we know 1 hour=3600 secs. In min we calculated seconds divided by 60 as we know that 1 min = 60secs.
As it is told to convert into seconds again therefore we multiplied min by 60 and then it was printed with the help of system.out.println
Thank you