DOC PREVIEW
UGA CSCI 1301 - Lab 6

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CSCI 1301 – Lab #6 Exercise The purpose of this exercise is to apply your knowledge about conditional statements discussed during the lectures. Write a java program that contains a class called Time with a main method that asks the user to enter an integer that represents the time in seconds in a day and displays the time in hours, minutes and seconds in both 12 hours AM/PM format and standard time. The main difference between AM/PM format and standard time format is how hours are expressed. Standard time format, the hours are numbered from 0 to 23. On the other hand, AM/PM time format uses numbers 1 to 12 to identify each of the 24 hours in a day. Additionally, you should note that the standard time hour zero corresponds to the AM/PM hour as 12, not 0. The output of your program should look similar to the output shown in the following examples. Example #1 Please enter the time in seconds: 48236 Standard Format: 13 h., 23 m., 56 s. AM/PM Format: 1 h., 23 m., 56 s. PM Example #2 Please enter the time in seconds: 30600 Standard Format: 8 h., 30 m., 0 s. AM/PM Format: 8 h., 30 m., 0 s. AM Example #3 Please enter the time in seconds: 908 StandardFormat: 0 h., 15 m., 8 s. AM/PM Format: 12 h.,15 m., 8 s. AM Your program should declare three int constants: • SECONDS_X_HOUR with value 3600 that represents the number of seconds in a minute. • SECONDS_X_MINUTE with value 60 that represents the number of seconds in a minute. • AM_PERIOD with value 43199 representing the number of seconds between midnight and 11:59:59 a.m., just one second before noon.Hints: • An hour has 3600 seconds. • A minute has 60 seconds. • • To find the hours, minutes and seconds of a time in seconds proceed as follows: Divide the seconds entered by the user by the number of seconds in an hour (SECONDS_X_HOUR), the result will be the hours in standard time. Compute the remainder of seconds entered by the user by the number of seconds in an hour (SECONDS_X_MINUTE). Divide the remainder obtained in the previous step by the number of seconds in a minute, the result of this division will be the minutes. The remainder of this last division will be the seconds. The number of hours in AM/PM format is the remainder of dividing the hours in standard time computed in (1) by 12. Use a decision statement to determine if the number of hours in AM/PM format is zero and set the AM/PM hours correctly to 12. • Use the appropriate decision statement to determine whether the number of seconds corresponds to an AM or PM time. Compile, run and test your program. After you have completed this exercise,demonstrate it to your lab instructor. WebCT Submission After you have completed both exercises in this lab, upload the file Time.java in WebCT andsubmit it to receive


View Full Document

UGA CSCI 1301 - Lab 6

Documents in this Course
Load more
Download Lab 6
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 6 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 6 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?