0

Task 1 This assignment will consist of writing a couple of small programs that involve practice writing
Filename: Seconds.java In a class called Seconds:

1.  Write a method called toSeconds that takes in three integer parameters (representing hours, minutes, and seconds) and returns the number of seconds since the last time the clock "struck 12" (i.e. was at 12:00:00 -- AM or PM doesn't matter since you're not tracking this). Your method should be declared public and static. 
  1. To test this method, write a main() routine (in the same class) that prompts the user to enter hours, minutes, and seconds for two different clock times; then uses the toSeconds method to calculate the shortest amount of time in seconds between the two times (both of which are within one 12-hour cycle of the clock); the print out the number of seconds since "striking 12" for both clocks, as well as the number of seconds between the two clock times
    Sample Run 1:
    (user input underlined)
    Input first clock time...
    Hours: 6
    Minutes: 45
    Seconds: 30

Input second clock time...
Hours: 4
Minutes: 50
Seconds: 12

It's been 24330 seconds since the first clock struck 12:00
It's been 17412 seconds since the second clock struck 12:00
The two times are 6918 seconds apart.
Sample Run 2:
(user input underlined)
Input first clock time...
Hours: 12
Minutes: 43
Seconds: 16

Input second clock time...
Hours: 7
Minutes: 11
Seconds: 59

It's been 2596 seconds since the first clock struck 12:00
It's been 25919 seconds since the second clock struck 12:00
The two times are 23323 seconds apart.

2
Contributors
1
Reply
9
Views
3 Years
Discussion Span
Last Post by JamesCherrill
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.