Seconds - final int SECONDS_PER_MINUTE = 60; int seconds,...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************************** // Seconds.java Author: Lewis and Loftus // // Solution to Programming Project 2.6 //******************************************************************** / import java.util.Scanner; i public class Seconds { //----------------------------------------------------------------- // Computes the number of hours, minutes, and seconds that are // equivalent to the number of seconds entered by the user. //----------------------------------------------------------------- public static void main (String[] args) { final int SECONDS_PER_HOUR = 3600;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: final int SECONDS_PER_MINUTE = 60; int seconds, minutes, hours; Scanner sc = new Scanner(System.in); System.out.print ("Enter the number of seconds: "); seconds = sc.nextInt(); hours = seconds / SECONDS_PER_HOUR; seconds = seconds % SECONDS_PER_HOUR; // still remaining minutes = seconds / SECONDS_PER_MINUTE; seconds = seconds % SECONDS_PER_MINUTE; // still remaining System.out.println (); System.out.println ("Hours: " + hours); System.out.println ("Minutes: " + minutes); System.out.println ("Seconds: " + seconds); } }...
View Full Document

Ask a homework question - tutors are online