67 172
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #16978 in Java | JSP | JSF for marky

Question #16978
Write a program that allows you to display a number in Second, Display is equivalent in Hour: Minute: Second
Expert's answer
import java.util.Scanner;




public class q16978 {




public static void main(String[] args) {

System.out.print("Please input the number of seconds: ");

Scanner in = new Scanner(System.in);

int numOfSeconds = in.nextInt();

System.out.print(numOfSeconds + " seconds = ");



int hours = numOfSeconds / 3600;

numOfSeconds = numOfSeconds % 3600;

int minutes = numOfSeconds / 60;

numOfSeconds = numOfSeconds % 60;

System.out.println(hours + " hours, " + minutes + " minutes, " + numOfSeconds + " seconds.");

}




}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions