Computer Science, asked by pritymall1982, 8 months ago

Q4. Write a program that takes a number of seconds as input. The program converts this value to the corresponding
number of hours, minutes, and seconds and displays these values.
Example :
Input : Second
5000
Output : Hours
Minutes
23
Seconds
20

please in bluej language fast no wrong answer please my exam is there​

Answers

Answered by harnathyadav2907
2

Answer:

import java.util.Scanner;

public class SecondstoHrMinSec

{

public static void main(String[] args)

{

// create object of scanner class.

Scanner in = new Scanner(System.in);

// enter the seconds here.

System.out.print("Enter seconds : ");

int seconds = in.nextInt();

int p1 = seconds % 60;

int p2 = seconds / 60;

int p3 = p2 % 60;

p2 = p2 / 60;

System.out.print("HH:MM:SS - " +p2 + ":" + p3 + ":" + p1);

System.out.print("\n");

}

}

Answered by Equestriadash
5

Note that the following codes are written in Python.

choice = "Yes"

while choice == "Yes":

   n = =float(input("Enter a time [in seconds]: "))

   print()

   print(s/3600, "is the time in Hours.")

   print()

   print(s/60, "is the time in Minutes.")

   print()

   choice = input("Would you like to go again? [Yes/No]: ")

   print()

Output:

Attachments:
Similar questions