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
1
Expert's answer
2012-10-23T09:22:08-0400
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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS