(URI) Tempo de Jogo - Solution

import java.io.*;

class Main  {
    public static void process() throws NumberFormatException, IOException {   
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
           
        String line = br.readLine();   
        String[] hours = line.split(" ");
        int start = Integer.parseInt(hours[0]);
        int end = Integer.parseInt(hours[1]);
       
        int result = 0;
        if (start == end) {
            result = 24;
        }
        else if (end < start) {
            int day1 = 24-start;
            int day2 = end;
            result = day1+day2;
        }
        else {
            result = end-start;
        }
        System.out.println("O JOGO DUROU " + result + " HORA(S)");
               
        return;
    }
   
    public static void main(String[] args) throws NumberFormatException, IOException {
        Main m = new Main();
        m.process();

        System.exit(0);
    }
}

Comments

Popular posts from this blog

(Coderbyte) Powers of Two - Solução

(Coderbyte) Dash Insert II - Solução

(CoderByte) Number Search - Solução