-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecondsToHMS.java
More file actions
27 lines (24 loc) · 1010 Bytes
/
SecondsToHMS.java
File metadata and controls
27 lines (24 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* @class: SecondstoHMS
* @author: Hugo Padilla
* @course: ITEC 2140 - 05, Spring 2023
* @version: 1.0
* @date: February 5th, 2023
* @description: This program will take a user inputted seconds, and convert it to the
* corresponding amount of hours, minutes, and seconds.
*/
package TextbookHomework2;
import java.util.Scanner;
public class SecondsToHMS {
public static void main (String[] args){
Scanner ben = new Scanner (System.in);
System.out.print("Enter a value in seconds: ");
int seconds = ben.nextInt();
int hours = seconds/3600;
int remainingSeconds = seconds%3600; // takes the remaining seconds after calculating hours
int minutes = remainingSeconds/60; // and converts them to minutes
remainingSeconds = remainingSeconds%60;
System.out.println(seconds + "seconds would equal " + hours + "hours, " + minutes + "minutes, and " + remainingSeconds + "seconds.");
ben.close();
}
}