Computer Science, asked by amanjshaikh5454, 1 day ago

Write a program in Java to initialize a ‘seconds’ as 4250, and display the seconds in the form Hours, Minute and Seconds. Example: 4000 1 Hour 6 Minutes and 40 Seconds​

Answers

Answered by ITZURADITYAKING
4

Answer:

import java.util.Scanner;

public class KboatTime

{

public static void main(String args[]) {

Scanner in = new Scanner(System.in);

System.out.print("Time in seconds: ");

int inputTime = in.nextInt();

int hrs = inputTime / 3600;

int mins = (inputTime % 3600) / 60;

int secs = (inputTime % 3600) % 60;

System.out.println(hrs

+ " Hours "

+ mins

+ " Minutes "

+ secs

+ " Seconds")l

Answered by ay8076191
2

Explanation:

hlo mate here's your answer

Approach:

h hours = h * 60 minutes as 1 hour = 60 minutes.

Similarly h hours = h * 3600 seconds.

Note: To convert m minutes back into hours, do n / 60 and for s seconds s / 3600.

Below is the implementation of the above approach:

I hope its help you mark as brainlist

Similar questions