Computer Science, asked by ashamishra170pci228, 1 year ago

write a program to input time in seconds and display the time broken as hours minutes and seconds in java?

Answers

Answered by shantanurauthan
16

I haven't executed this program so kindly tell me in the comments .Does it work or not?

import java.util.Scanner;

public class Time {

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.println("Enter seconds");

int s = in.nextInt();

int sec = s % 60;

int min = (s / 60)%60;

int hours = (s/60)/60;

System.out.println(hours + ":" + min + ":" + sec);

}

}


ashamishra170pci228: thnk you thnk you sn much
shantanurauthan: No problem bro just rate the question if you like it
Similar questions