COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Fundamentals HelloWorld.java Basics.java Payroll.java Cartons.java Time.java DollarAmount.java StringPractice.java PayrollGUI.java



Time Program


Description

The purpose of this program is to input a time in seconds then calculate the hours, minutes, and seconds, and print the time in hours:minutes:seconds format.

Associated Concepts:

Division operator / and modulus operator %

Algorithm:

Declare variables to store data items

Read a time in seconds

Use division operator / and modulus operator % to figure out hours, minutes, and seconds

Hint: 1 minute = 60 seconds and 1 hour = 3600 seconds

Print the result

Source Code



Sample Run



Video