Skip to content

Commit 77d95c2

Browse files
committed
Time Convert
1 parent 207a109 commit 77d95c2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/easy/TimeConvert.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package easy;
2+
3+
/**
4+
* Have the function TimeConvert(num) take the num parameter being passed
5+
* and return the number of hours and minutes the parameter converts to
6+
* (i.e. if num = 63 then the output should be 1:3).
7+
* Separate the number of hours and minutes with a colon.
8+
*/
9+
public class TimeConvert {
10+
11+
/**
12+
* Time Convert function.
13+
*
14+
* @param num input number
15+
* @return the number of hours and minutes
16+
*/
17+
private static String timeConvert(int num) {
18+
int hours = num / 60;
19+
int minutes = num % 60;
20+
return hours + ":" + minutes;
21+
}
22+
23+
/**
24+
* Entry point.
25+
*
26+
* @param args command line arguments
27+
*/
28+
public static void main(String[] args) {
29+
var result1 = timeConvert(63);
30+
System.out.println(result1);
31+
var result2 = timeConvert(178);
32+
System.out.println(result2);
33+
var result3 = timeConvert(249);
34+
System.out.println(result3);
35+
}
36+
37+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy