Time Convert Coderbyte Solution

0

Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon.


Time Convert Coderbyte Solution Java


import java.util.Scanner;



public class TimeConvert {
String TimeConvert(int num) {
int hours = num / 60;
int min = num % 60;

return hours + ":" + min;

}

public static void main (String[] args) {
// keep this function call here
Scanner s = new Scanner(System.in);
TimeConvert c = new TimeConvert();
System.out.print(c.TimeConvert(s.nextInt()));
}
}


Time Convert Coderbyte Solution Javascript

Using the JavaScript language, have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon. 


function TimeConvert(num) {

var hours = Math.floor(num / 60);
var minutes = num % 60;
return hours + ":" + minutes;
}


Time Convert Coderbyte Solution Python


def TimeConvert(num):
return "{hour}:{minute}".format(hour=num / 60, minute=num % 60)


def TimeConvert2(num):
return str(num / 60) + ":" + str(num % 60)


# keep this function call here
# to see how to enter arguments in Python scroll down
print TimeConvert(raw_input())

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !