(Coderbyte) Time Convert - Solução

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.

Solução:

import java.util.*;
import java.io.*;

class Function { 
  String TimeConvert(int num) {
 
    int hora = num / 60;
    int minuto = num % 60;

    return hora + ":" + minuto;
   
  }
 
  public static void main (String[] args) { 
    // keep this function call here    
    Scanner  s = new Scanner(System.in);
    Function c = new Function();
    System.out.print(c.TimeConvert(s.nextLine()));
  }  
 
}          

Comments

Popular posts from this blog

(Coderbyte) Dash Insert II - Solução

(Coderbyte) Run Length - Solução

(Coderbyte) Counting Minutes I - Solução